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
-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to cURL,
- Hide cURL Outputs and Errors on Terminal
- cURL DELETE Request with Examples
- Downloading Google Chrome using cURL Command
- List of 28 Protocols supported by cURL with Examples
- Get the Size of HTTP Response using cURL Command (Content Length)
- How to convert a Postman request to cURL Command
- How to URL Encode Data for a cURL Request Parameters
- Get cURL command from Chrome Inspect Network HTTP URL
- Fetch only content-type using cURL Command
- cURL -d Option with Examples
- cURL Option to show HTTP Response Status Code
- URL Encode cURL HTTP GET\POST Data with Examples
- How to get cURL Command to run in verbose mode?
- trurl: A new command-line tool for URL parsing and manipulation by cURL Developer
- [fix] command not found curl
- How to Pretty Print cURL JSON Output in Terminal
- Capture cURL Request Output to a File
- List of common cURL Error Codes
- How to pass authorization header using cURL
- Perform Basic Authentication using cURL with Examples
- Trace using cURL Command Example
- Efficient way to perform HTTP cURL GET/POST Requests with Payload
- Save cURL Command Output to a external file
- cURL Example using IP (IPv4 and IPv6) address and Port
- How to follow redirects in cURL Command Request
More Posts:
- How to integrate Salesforce CRM Sales and Service with Microsoft Teams - Teams
- JavaScript: Count Words in a String - JavaScript
- Java Decompiler Eclipse Plugin - Eclipse
- [Python] Fix: TypeError: NoneType object is not subscriptable - Python
- Calculate Volume of Cube - C-Program
- Parsing CSV file using Java code example (Comma Separated File) - Java
- How to Create Awesome Quizzes using Windows 365 Forms - Windows
- Shortcut: Cut (or Delete) current line in Visual Studio Code (VSCode) - HowTos