post-json tagged requests and articles

Categorized request examples and articles tagged with [post-json] keyword
How do I post JSON to a REST API endpoint?
To post JSON to a REST API endpoint {{using LANG}}, you must send an HTTP POST request to the REST API server and provide JSON data in the body of the {{LANG}} POST message. You must also specify the data type using the Content-Type: application/json request header. In this {{LANG}} REST API POST example, we also send the Accept: application/json request header to tell the REST API server that the {{LANG}} API client expects JSON in response.

How to post JSON using Curl?
To post JSON data using Curl, you need to set the Content-Type of your request to application/json and pass the JSON data with the -d command line parameter. The JSON content type is set using the -H "Content-Type: application/json" command line parameter. JSON data is passed as a string. Double quotes in JSON must be escaped with the backslash "\" on Windows computers. In this Curl POST JSON example, we send JSON to the ReqBin echo URL. Click Run to execute the Curl POST JSON example online and see result.

How do I post JSON to the server?
To post JSON data to the server{{ using LANG}}, you need to provide the JSON data in the HTTP POST request body and pass the "Content-Type: application/json" request header. The Content-Type request header specifies the media type for the resource in the body. Additionally, you can pass an "Accept: application/json" header, which tells the server that the client is expecting JSON data. In this {{LANG}} POST JSON example, we send JSON data to the ReqBin echo URL with the appropriate Accept and Content-Type HTTP headers. Click Send to execute the {{LANG}} POST JSON example online and see the results.

How do I POST JSON with Bearer Token Authentication?
To post JSON with a Bearer Token Authorization header{{ using LANG}}, you need to make an HTTP POST request, provide your Bearer Token with an "Authorization: Bearer {token}" HTTP header, and give the JSON data in the body of the POST message. The "Accept: application/json" header tells the server that the client expects JSON from the server. For security reasons, bearer tokens are only sent over HTTPS (SSL). In this {{LANG}} POST JSON with Bearer Token Authorization Header example, we send a request to the ReqBin echo URL with Authorization: Bearer {token} HTTP header. Click Send to execute the {{LANG}} POST JSON request with a Bearer Token Authorization Header example online and see results.

How do I post request body with Curl?
To send data to the server in the POST request body, you must pass the required data to Curl using the -d or --data command line switch and specify the data content type using the -H command line switch. The Content-Type header is required for the server to correctly interpret and process the data in the body of the POST message. For example, if you send JSON to a server, you must specify the content type of the data in the body of the POST message using the Content-Type header: application/json and application/xml for XML. In this example, we send the request body to the ReqBin echo URL using Curl. Click Run to execute Curl POST Body example online and see results.

How do I POST JSON string with Basic Authentication?
To post JSON to a server with Basic Authentication credentials, you need to make an HTTP POST or PUT request, include the JSON in the body of the HTTP message, and pass the "Authorization: Basic [token]" HTTP header to the server. The [token] is a Base64 encoded string of user credentials in the form of a login:password string. In this POST JSON with a Basic Authentication Credentials Example, we send a POST request with JSON body and "Authorization: Basic [token]" header to the ReqBin echo URL. Click Send to execute POST JSON with Basic Authentication example online and see the results.

How to send request to the REST API endpoint?
To send a request to the REST API endpoint, you must enclose a JSON data in the request body and indicate the data type with the "Content-Type: application/json" request header. The client also can send the "Accept: application/json" request header, which indicates that the client wants to receive the data in JSON format. If the REST API server returns a JSON, it indicates the type of data in response with the "Content-Type: application/json" response header. In this REST API Example, we are sending JSON data to the ReqBin echo URL with Accept: application/json HTTP header. Click Send to make a REST API request online and see the results.

What is the correct Content Type for JSON?
The correct content type for JSON is application/json, and the correct content type for JSONP (padded JSON) is application/javascript. For JSON-LD (JSON-linked data), the correct content type is application/ld+json. Legacy JSON content types, such as text/json, text/x-json, and text/javascript, should be avoided. The Content-Type HTTP header is used to indicate the type of media in the body of the HTTP message. The default encoding for JSON (JavaScript Object Notation) is UTF-8. In this {{LANG}} JSON Content-Type example, we send JSON to the ReqBin echo URL with an application/json Content-Type header. Click Send to execute the {{LANG}} JSON Content-Type request online and see the results.

How do I post JSON using the Python Requests Library?
To post a JSON to the server using Python Requests Library, call the requests.post() method and pass the target URL as the first parameter and the JSON data with the json= parameter. The json= parameter takes a dictionary and automatically converts it to a JSON string. The Request Library automatically adds the Content-Type: application/json header to your request when using the json= parameter. In this Python Requests POST JSON example, we send a JSON data string to the ReqBin echo URL. Click Execute to run the Python POST JSON example online and see the result.

REST API Testing Tool
Online REST API testing tool for API developers and testers. Test your RESTful API by making API calls directly from your browser.