Curl Post Data From Terminal with Examples Simple POST Example. We will start with a simple POST example. We will provide some fields in the POST with the –data. Read POST Data From File. What if we have more data that is not suitable to write one by one of specifying from command. The basic problem is that I can't seem to use postForm to pass an un-keyed string as part of the data option in curl, i.e. Curl -d 'string' 'addresstoapi'. For example, from the command line I might do. CURL is a free and open-source command-line utility used for transferring data to or from a remote host with minimal user interaction. It allows users to upload and download data either using single commands or bash scripts. It is safe to say that cURL is more than an HTTP client. How to use cURL Post data from the file is explained in this article.
Question- How to POST JSON data with curl? How to POST JSON data with curl command line? How do I POST JSON data on Linux terminal?
You can add -H 'Content-Type: application/json'
header value to Post the JSON data to curl command line.
Curl Post With Header And Body
Curl Post Data Form
For example, I have an API URL https://api.example.com/v2/login
, that is used to authenticate the application. Now passing the username and password in JSON format using the curl command line tool.
Curl Post Data Form
You can also write the username and password in a user.json file. Now use this file to pass the JSON data to curl command line.