Vishnu Ranganathan Vishnu Ranganathan - 1 month ago 5
JSON Question

How to make a POST call with JSON data using curl?

I have tried only GET calls using curl, and now I need to make a POST call. I need to give the parameters or input using JSON. How do I write this command?

Answer

Assuming you are asking how to format a curl POST request with JSON attributes.

curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d "{'json':{'key':'value'}}" http://your.domain/endpoint/here

This page covers a lot of useful cases.