Send JSON Data as Payload using cURL HTTP POST Request

In order to send JSON data as payload with an HTTP Post cURL request you need to add,


1. The JSON Header for Content-type

-H "Content-Type: application/json"

2. Include the JSON data payload using --data flag

--data '{"city":"USA","state":"New York"}' 

Complete Example

curl -X POST \
-H "Content-Type: application/json" \
--data '{"city":"USA","state":"New York"}' \
http://example.com/api/endpoint
cURL with HTTP POST JSON Data Payload Example

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!