HTTP POST URL Encoded (application/x-www-form-urlencoded)

Back to HTTP Tutorial Index

An HTTP POST with Content-Type equal to "application/x-www-form-urlencoded" is a POST where the query parameters are sent in the body of the request using the same format as when the query params are in the URL following the "?".

Here's a sample POST with URL query params located in the body of the HTTP request:

POST https://example.com/v2/reports HTTP/1.1
Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json
Host: example.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 203

endDate=2015-12-31&filters=video%3D%3Djb42oy5_ruI&ids=channel%3D%3DMINE&metrics=views%2Ccomments%2Clikes%2Cdislikes%2CestimatedMinutesWatched%2CaverageViewDuration&startDate=2015-01-01&key=[YOUR_API_KEY]

You can generate the CURL statement from the above HTTP request using Chilkat's online tool at https://tools.chilkat.io/httpToCurl

CURL

A CURL statement to send the above HTTP request is shown here. You can generate source code from a CURL statement using Chilkat's online tool at https://tools.chilkat.io/curlHttp

In the CURL statement, no URL encoding is needed because each name=value pair is enclosed in double-quotes.

curl -X POST https://example.com/v2/reports \
  -H "Authorization: Bearer [YOUR_ACCESS_TOKEN]" \
  -H "Accept: application/json" \
  -H "Host: example.com" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "endDate=2015-12-31" \
  -d "filters=video==jb42oy5_ruI" \
  -d "ids=channel==MINE" \
  -d "metrics=views,comments,likes,dislikes,estimatedMinutesWatched,averageViewDuration" \
  -d "startDate=2015-01-01" \
  -d "key=[YOUR_API_KEY]"

Chilkat Examples Implementing the Above HTTP POST

You can use Chilkat's online tool at https://tools.chilkat.io/curlHttp to generate code from a CURL statement. Copy/paste the CURL statement into the online tool, choose your programming language, and click the "Generate Code" button.