How do I post JSON to the JSON API endpoint?

To send JSON data to a JSON API endpoint, you must include the JSON data in the body of the POST request message and specify the JSON media type with the Content-Type: application/vnd.api+json request header. The client must also send an Accept: application/vnd.api+json request header to tell the server that it is expecting a JSON API response from the server. Click Send to execute the JSON API Example online and see the results.
How do I post JSON to the JSON API endpoint? Send
POST /echo/post/json HTTP/1.1
Host: reqbin.com
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json
Content-Length: 52

{
  "Id": 78912,
  "Quantity": 1,
  "Price": 18.00
}
Updated: Viewed: 33081 times

What is JSON?

JavaScript Object Notation (JSON) is a standard textual format for storing and transmitting data over a network. JSON is used in almost all scripting languages, including JavaScript, Python, Java, C++, C#, Go, PHP, and many others. JSON is widely used for client/server communication, transferring data to and from the server in web and mobile applications.

What is API?

Application Programming Interface (API) is a software intermediary for creating and integrating application software that allows two applications to exchange data. APIs conform to REST and HTTP standards, are easy to use and are developer-friendly. The APIs are well documented for use and version control. The API has its software development lifecycle (SDLC), which includes designing, testing, building, managing, and versioning, just like any other software produced.

What is JSON API?

JSON API is a text-based data exchange format designed to work with HTTP. The JSON API defines how clients should request data from the server and how the server should respond to requests. The JSON API provides improved caching functionality and optimizes HTTP requests by eliminating unnecessary server requests. JSON API is described at JSONAPI.org and differs from REST API.

What are the benefits of the JSON API?

The main advantage of the JSON API is that it reduces both the number of requests and the amount of data transferred between clients and servers.

How to Send a JSON API Request?

JSON API clients and servers should send requests and responses with the following HTTP header:

Content-Type Header Example
Content-Type: application/vnd.api+json

JSON API clients must also send an Accept header to tell the server that they can accept JSON API requests.

Accept Header Example
Accept: application/vnd.api+json

JSON API Request Example

An example of sending a JSON API request that we send to the echo ReqBin URL:

JSON API Example
POST /echo/post/json HTTP/1.1
Host: reqbin.com
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json
Content-Length: 52
      
{
  "Id": 78912,
  "Quantity": 1,
  "Price": 18.00
}

See also

Generate Code Snippets for JSON API Example

Convert your JSON API request to the PHP, JavaScript/AJAX, Curl/Bash, Python, Java, C#/.NET code snippets using the ReqBin code generator.