PHP code for Curl JSON Request ExampleThis PHP code snippet was generated automatically for the Curl JSON Request example.
<< Back to the Curl JSON Request example
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?
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: