request-header tagged requests and articles

Categorized request examples and articles tagged with [request-header] keyword
POST JSON Example
An example of posting a JSON string to the REST API endpoint. In this post JSON example, the Content-Type: application/json request header indicates the media type of the resource in the request body. The Accept: application/json request header tells the server that the client expects JSON. The Content-Type: application/json response header indicates that the server returned JSON.

Curl Request With Bearer Token Authorization Header
An example of a Curl request with Bearer Token Authorization header. The bearer token is sent to the server in the 'Authorization: Bearer {token}' authorization header. The 'Accept: application/json' header tells the server that the client expects a JSON. The server informs the client that it returned a JSON with 'Content-Type: application/json' response header.

GET JSON Example
An example of getting JSON from the URL. In this get JSON example, the client sends an Accept: application/json request header to the provided URL to tell the server that it expects JSON. The Content-Type: application/json response header informs the client that the server has returned JSON.

Curl POST JSON Example
An example of a Curl command to post JSON to the API endpoint. To post JSON with Curl, you need to set the content type to application/json. This is done by the -H "Content-Type: application/json" command-line option. The JSON is passed with the curl -d option. Double quotes in JSON are escaped with \".

GET Request With Bearer Token Authorization Header
An example of sending a GET request with Bearer Token authorization header. The bearer token is sent to the server in the 'Authorization: Bearer {token}' request header. The 'Accept: application/json' header tells the server that the client expects a JSON. The server informs the client that it returned a JSON with 'Content-Type: application/json' response header.

Curl POST XML Example
An example of a Curl command to post an XML string to the API endpoint. In this post XML request example, the 'Content-Type: application/xml' request header indicates that the request body contains an XML. The 'Accept: application/xml' request header tells the server that the client expects an XML. The XML is passed in the Curl -d command-line parameter.

GET XML Example
An example of getting an XML data from a website. The Accept: application/xml request header tells the server that the client expects an XML. The Content-Type: application/xml response header informs the client that the server returned an XML string.

REST API GET Example
An example of sending a GET request to the REST API endpoint. In this REST API GET example, the Accept: application/json request header tells the server that the client expects a JSON string. The Content-Type: application/json response header indicates that the server returned JSON for this GET request.

Curl GET XML Example
An example of a Curl command to get and an XML data from the API endpoint. The Accept: application/xml request header tells the server that the client expects an XML response. The Content-Type: application/xml response header informs the client that the server returned an XML string.

Send Custom Headers with Curl
An example of posting a custom header with Curl. To add a custom header to curl, you need to pass the -H "header: value" command line parameter to the curl request. The target url is passed as the first parameter.

Curl Command With Keep-Alive Connection Header
An example of a Curl request with connection and keep-alive headers. The Connection header is passed with the -H "Connection: keep-alive" command-line parameter. The Keep-Alive header is passed with the -H "Keep-Alive: timeout=5, max=100" command-line parameter.

GET Request With Custom Headers
An example of sending a custom request header to the server. In this example, the name of the custom header is X-Real-IP and the value is 39.40.130.50.

Keep-Alive Connection Example
This page shows how to establish a persistent connection with the server using the Connection and Keep-Alive headers. The Connection: keep-alive request header indicates that the client needs a persistent connection. The Keep-Alive: timeout=5, max=100 sets the timeout value.

Curl Add Header
An example of adding a header to the Curl request. Use the -H command-line option to set the Curl header details. In this Curl Add Header example, the -H "Content-Type: application/json" command-line option indicates the media type of the resource, and the Accept: application/json header tells the server that the client expects JSON.

Request Cookies
An example of sending a request with cookies in the header. Cookies are sent to the server in the Cookie: name=value request header. To send multiple cookies in a single Cookie header, separate them by a semicolon, or add multiple Cookie: name=value request headers.

Curl Send Cookies
An example of sending cookies with Curl. Cookies are passed to Curl with the --cookie "Name = Value" command-line parameter. Curl automatically converts the passed parameter into the Cookie: Name=Value request header.

Send Cookies Example
An example of sending HTTP cookies in the request header. Browsers send cookies to the server by adding the Cookie: name=value request header. Multiple cookies can be sent in a single Cookie header, separated by semicolon.

REST API Example
An example of sending JSON data to the REST API endpoint. The Accept: application/json request header indicates that the client wants to receive data in JSON format. The Content-Type: application/json response header informs the client that the server has returned JSON.

HTTP Headers
The browser and server use HTTP headers to pass the information on data size and type, compression methods, languages, cache directives, and origin.