Skip to content
HTTP 400 Bad Request — What It Means & How to Debug

HTTP 400 Bad Request — What It Means & How to Debug

DodaTech Updated Jun 20, 2025 4 min read

HTTP 400 Bad Request means the server cannot process the request due to malformed syntax, invalid parameters, or incorrect request structure from the client.

What It Means

The HTTP 400 Bad Request status code indicates the server could not understand or process the request because of client-side issues. Unlike a 404 Not Found (resource doesn’t exist) or a 500 Internal Server Error (server malfunction), a 400 means the server received something it couldn’t make sense of — malformed JSON, missing required fields, invalid data types, or incorrect request formatting.

The response body typically includes an error message or validation details explaining what went wrong, helping the client fix the request and resubmit.

When It’s Sent

  • Malformed JSON or XML in the request body
  • Missing required fields in a POST/PUT request
  • Invalid data types — sending a string where a number is expected
  • Validation failures — email format is wrong, password is too short
  • Oversized payloads — request body exceeds the server’s size limit

Real Example

curl -X POST https://api.example.com/users \
  -H "Content-Type: application/json" \
  -d '{"name": "Alice", "email": "not-an-email"}'

Expected response:

< HTTP/1.1 400 Bad Request
< Content-Type: application/json
<
{"error":"Validation failed","details":{"email":"Must be a valid email address"}}

The server rejected the request because the email format was invalid and returned a descriptive error.

How to Debug

Browser DevTools

  1. Open the Network tab
  2. Trigger the action that causes the error
  3. Find the request with status 400 (shown in red)
  4. Click it and go to the Preview or Response tab to read the error message
  5. Check the Payload tab to see exactly what data was sent

curl

curl -v -X POST https://api.example.com/users \
  -H "Content-Type: application/json" \
  -d '{"name":"Test"}'

The response body usually contains the validation error. Add -v to see the full request and response headers.

Postman

The status badge shows 400 Bad Request in red. The Body tab displays the error response. Use the Body tab in the request section to verify the data being sent.

How to Fix

  • Validate JSON syntax — use a JSON validator (like jq . or jsonlint.com) before sending
  • Check required fields — compare your payload against the API documentation
  • Verify data types — ensure numbers are numbers, strings are strings, booleans are true/false
  • Check Content-Type header — must match the request body format (usually application/json)
  • Limit payload size — stay under the server’s max body size (typically 1MB–10MB)
  • URL-encode query parameters — special characters in query strings must be percent-encoded

Common Causes

ScenarioWhat HappensWhy It Matters
Invalid JSONBody has trailing comma, missing quote, or syntax errorServer can’t parse the request at all
Missing required fieldPOST body omits a mandatory fieldServer rejects the incomplete data
Wrong data typeSending "age":"twenty" instead of "age":20Server’s type check fails
Oversized payloadUploading a 50MB file to a 10MB limit endpointServer cuts off the request
Invalid query paramsUsing ?date=invalid-formatServer can’t parse the parameter value

FAQ

What is the difference between 400 Bad Request and 422 Unprocessable Entity?
400 Bad Request is for malformed syntax or structural issues (invalid JSON, missing headers). 422 Unprocessable Entity is for semantic validation failures (valid JSON with invalid business logic). Some APIs use 400 for all client errors, but the HTTP specification recommends using 422 for validation errors specifically.
Should I retry a 400 Bad Request?
No. A 400 error indicates a problem with the request itself — retrying the same request will fail again. Fix the request payload, headers, or parameters before retrying. The only exception is if the error is intermittent (like a dropped connection before the request reached the server, which is rare with 400).
How do I find what's wrong with my request?
Check the response body — most servers return a detailed error message or validation object. Use the -v flag with curl to see the full request and response. Compare your request against the API specification, and use a tool like Postman to build and test requests interactively.

Related Codes

  • HTTP 200 OK — what you get after fixing the request
  • HTTP 401 Unauthorized — another client-side error, but for missing auth
  • HTTP 403 Forbidden — authenticated but not permitted
  • HTTP 404 Not Found — resource doesn’t exist
  • HTTP 500 Internal Server Error — not your fault, it’s the server

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro