Why do I get a malformed JSON in request body in this cURL call?

后端 未结 2 1284
滥情空心
滥情空心 2021-01-11 16:43

I have been trying to call the CloudFlare API v4, using an example provided in their own documentation.

This is the code of the example

curl -X PUT \         


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-11 17:38

    Frank.Lowell, thank you for question!

    I found the answer in the blog post: "Expecting to find valid JSON in request body..." curl for Windows.

    For example, for Purge everything --data value will be:

    # On Linux
    --data '{"purge_everything":true}'
    
    # On Windows
    --data "{\"purge_everything\":true}"
    

    For Windows:

    1. Replace the single quotes with double quotes: ' --> "
    2. Escape the double quotes with a backslash: " --> \"

提交回复
热议问题