Curl Post Json Request

Apr 28, 2019
curl --header "Content-Type: application/json" \  --request POST \  --data '{"name": "Desmond Lua", "age": 40}' \  [URL]

or

curl -X POST -d '{"name": "Desmond Lua", "age": 40}' -H "Content-Type:application/json" [URL]

Send JSON from file

curl -X POST -d @test.json -H "Content-Type: application/json" [URL]


**NOTE:** If you test REST api frequently, do consider tools like [Postman or Insomnia][tools-to-test-rest-api]

[tools-to-test-rest-api]: /tutorials/linux/tools-to-test-rest-api/

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.