Reputation: 2662
I have to post JSON as request in cURL as
curl -H 'Content-Type: application/json' -X POST http://localhost:3000/users.json\ -d "{"user" : {"email":"[email protected]", "password":"qwerty", "password_confirmation":"qwerty"}}"
but this displays a Multi_json decode
error.
It accepts this instead.
curl -H 'Content-Type: application/json' -X POST http://localhost:3000/users.json -d "{\"user\" : {\"email\":\"[email protected]\", \"password\":\"qwerty\", \"password_confirmation\":\"qwerty\"}}"
How can I send the JSON without escaping it?
Upvotes: 0
Views: 2619
Reputation: 943220
This has nothing to do with cURL or JSON.
The real question here is: "How do I pass an argument containing quote characters in bash?" (or whatever shell is being used to access the command line curl application).
Quote the string with '
characters instead of "
characters.
This will only work if the data does not include '
characters.
Upvotes: 4