application/x-www-form-urlencoded application/x-www-form-urlencoded means: application/x-www-form-urlencoded is the media type for HTML form data encoded as key=value pairs joined by ampersands, with spaces and special characters percent-encoded. It is the default encoding for simple form POSTs and the body format many OAuth and legacy APIs expect. Application media types carry structured or binary data that a program consumes rather than a human reading raw bytes. The subtype tells the receiver exactly which parser, decoder or handler to invoke, so sending the correct Content-Type is part of the API contract: a mismatch makes servers reject the body with 415 Unsupported Media Type or clients mis-parse the payload. You will encounter application/x-www-form-urlencoded in contexts such as default html form submissions without file uploads; oauth 2.0 token requests and legacy api post bodies; query-string-style payloads sent in a request body. It is commonly associated with the file extension(s) no fixed file extension. This encoding flattens everything to strings and percent-escapes special bytes; it cannot represent nested structures or binary files. For uploads use multipart/form-data, and for structured data use application/json. Spaces become + in this format, not %20.
When you'll see application/x-www-form-urlencoded
- Default HTML form submissions without file uploads
- OAuth 2.0 token requests and legacy API POST bodies
- Query-string-style payloads sent in a request body
How to handle it
When handling an application type, set the Content-Type header explicitly on every request and response that carries a body, and advertise what you accept with the Accept header. Parse the payload with a library that matches the subtype rather than sniffing bytes, and validate the structure before trusting it. If a server returns 415, the declared type does not match what it expects — compare your header against the API documentation character for character, including parameters such as charset or boundary. As a final checklist for application types: register the exact subtype in your API documentation, validate incoming bodies against a schema before use, set X-Content-Type-Options: nosniff to stop MIME sniffing, and version your media types when the payload contract changes so old clients keep working.
Notes & gotchas
This encoding flattens everything to strings and percent-escapes special bytes; it cannot represent nested structures or binary files. For uploads use multipart/form-data, and for structured data use application/json. Spaces become + in this format, not %20.
Examples
POST /v1/resource HTTP/1.1
Host: api.example.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 40
name=Ada+Lovelace&role=admin&active=true curl -i -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "name=Ada+Lovelace&role=admin" https://api.example.com/v1/resource const body = new URLSearchParams({ name: "Ada Lovelace", role: "admin" });
const res = await fetch("/v1/resource", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body,
}); import requests
res = requests.post("https://api.example.com/v1/resource",
data={"name": "Ada Lovelace", "role": "admin"}, timeout=10)
# passing a dict to data= sends application/x-www-form-urlencoded by default Frequently asked questions
When should I use form-urlencoded vs multipart/form-data?
Use form-urlencoded for simple key-value fields with no files; use multipart/form-data when uploading files or sending mixed binary and text parts.
Why are spaces encoded as + here?
The form-urlencoded convention encodes space as +, while general percent-encoding uses %20. Decoders must treat + as space in this specific format.
What happens if I send the wrong application Content-Type?
Servers that validate media types answer 415 Unsupported Media Type, and clients may parse the body with the wrong decoder. Always set Content-Type to the registered type that matches your payload, and set Accept to the types you can handle.
Is application/octet-stream a safe default?
It means 'arbitrary binary bytes' and forces a download rather than inline handling. Use it only when the real type is unknown or you deliberately want a save-as dialog; otherwise declare the specific registered type.
How do I debug a 415 Unsupported Media Type response?
Compare the Content-Type you actually sent against what the endpoint documents, including parameters like charset and boundary. A 415 means the server refuses that media type; send the exact registered type it accepts and retry.
Try the URL Encoder
Percent-encode and decode URL components or full URLs.