Flask Restful Post Json Fails
I have a problem posting JSON via curl from cmd (Windows7) to Flask RESTful. This is what I post: curl.exe -i -H 'Content-Type: application/json' \ -H 'Accept: application/json' -
Solution 1:
-d '{"Hello":"Karl"}'
doesn't work from windows as its surrounded by single quotes. Use double quotes around and it will work for you.
-d "{\"Hello\":\"Karl\"}"
Solution 2:
I just want to point out that you need to escape regardless of OS - and regardless if you have double quotes around the request data - I saw this post and didn't think it was the answer to my issue because I had double quotes around the request data and single quotes inside:
This won't work:
-d "{'Hello': 'Karl'}"
This will:
-d "{\"Hello\":\"Karl\"}"
Again, you need to escape the quotes regardless of OS (I'm on Mac) and regardless of whether you have single or double quotes
And thanks Sabuj Hassan for your answer!
Solution 3:
To add-on to the previous two answers, you do not need to escape the quotes across all OS's, following this syntax will work just fine on Mac/Linux:
-d '{"Hello":"Karl"}'
Post a Comment for "Flask Restful Post Json Fails"