'How to escape special characters in json for curl command?
I want to use batch file to call API by curl command in Windows. But the JSON body have some special characters. How can I escape special characters in JSON?
setLocal EnableDelayedExpansion
set saveapiURL=http://localhost:8081/api/saveaddress
set cookiesFilename=cookies.txt
curl -X POST -H "Content-Type: application/json" -b !cookiesFilename! !saveapiURL! -k -d "{\"address\":\"Flat A&B, 2/F,\",\"phoneNo\":\"1234 5678\"}"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|