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\"}"
Great. This solved my problem.
I appreciate your posts. Thank you!
Muito obrigado!
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. 🙂
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”.
Thanks a lot – sometimes working in CMD feels like fighting the windmills
Thank you!
Obrigado!
Gracias!