What is Curl?
Client for URLs (Curl) is a popular command-line tool for Linux, Windows, and macOS that is commonly used for transferring files over networks using HTTP, HTTPS, FTP, or SFTP protocols. You can make GET, POST, and HEAD requests to the server, retrieve HTTP headers, download HTML pages, upload files, submit forms, and more.
What is JSON?
JavaScript Object Notation (JSON) is a textual data interchange format based on JavaScript. In the same way, as many other textual formats, JSON is easily readable by humans and parsed by computers. Despite its origins in JavaScript, this format is considered language-independent and compatible with most programming languages. For many programming languages, there is ready-made code for creating and manipulating JSON data.
Why to need to specify Content-Type when sending JSON with Curl?
If you do not explicitly specify the Content-type when submitting data using Curl, Curl uses the application/x-www-form-urlencoded content type. The -H "Content-Type: application/json" command line parameter must be specified when sending JSON (or any other data type).
How to send JSON with Curl?
The following is an example of sending JSON to Curl: