I'd let batch do the escaping by replacing all " with \"
set "json={"firstName":"First", "lastName":"last", "email":"[email protected]", "username":"user1", "password":"pass1"}"
set "json=%json:"=\"%"
echo curl -X POST -H "Content-Type: application/json" -d "%json%" 127.0.0.1:3001/users
Remove the echo in front of curl before using.
- If running a batch in powershell curl without extension will use the alias to Invoke-Webrequest instead of curl.exe
- I Windows 10 Version 1803 is curl.exe included (C:\Windows\system32\curl.exe V7.55.1.0)
- If you need a special version of curl the location
C:\Windows\system32\ is presumably before in the environment path, so include the path to your curl then.
'the same way a Unix shell would.