cURL post JSON data on Windows

On Windows, the key to send JSON data is double-quotes like this


-d "{\"name\":\"Spring Forever\"}"

cURL to POST a JSON data


 curl -X POST localhost:8080/books
	-H "Content-type:application/json" 
	-d "{\"name\":\"Spring Forever\",\"author\":\"pivotal\"}"

References

7 comments on “cURL post JSON data on Windows

  1. Escaping like this works on Windows only from command line. when you script then escape character is: ^ (it is not \). BTW if you use long access token or large data payload then you will exceed command line Windows limit of 1024 characters giving you odd and unrelated errors that Microsoft engineering could not figure out better message: “error: content truncated”.

  2. Thank you! I couldn’t figure out why the same command worked on Linux and not on Windows. This was the simple solution I needed. 🙂

Leave a Comment

Your email address will not be published. Required fields are marked *