Flask RESTful POST JSON fails

后端 未结 3 1611
隐瞒了意图╮
隐瞒了意图╮ 2021-02-10 04:33

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 \"Acce         


        
3条回答
  •  梦如初夏
    2021-02-10 04:44

    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!

提交回复
热议问题