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"}' \
cURL with HTTP POST JSON Data Payload Example

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X

Copyright © Code2care 2023 | Privacy Policy | About Us | Contact Us | Sitemap