400 Bad Request Error
Learn what 400 Bad Request means, common causes like malformed syntax or invalid request parameters, and how to fix them.
What Does This Error Mean?
The 400 Bad Request status code means the server cannot process the request due to malformed syntax, invalid request message framing, or deceptive request routing.
Common Causes
Malformed JSON or XML request body
Missing required query parameters
Invalid parameter values or types
Request entity too large for server limits
Content-Type header mismatch with request body format
Invalid HTTP method for the endpoint
How to Fix It
Validate request body format
Ensure the request body matches the Content-Type header and is well-formed.
// Check Content-Type matches body
fetch("/api/data", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(validData) // Must be valid JSON
})Check required parameters
Verify all required query parameters, headers, and body fields are present and have valid values.
// Example: required parameters GET /api/search?q=hello // ✅ Valid GET /api/search // ❌ Missing q parameter → 400
Inspect the error response
Most APIs include details in the response body explaining exactly what is wrong with the request.
fetch("/api/data").then(async res => {
if (res.status === 400) {
const error = await res.json()
console.log(error.message) // e.g., "Field email is required"
}
})Before & After Examples
POST /api/users
{"name":"John","age":"not-a-number"}POST /api/users
{"name":"John","age":30}Related Tools
Use these tools to debug and fix this error:
REST API Client
Send HTTP requests (GET, POST, PUT, DELETE) and inspect responses from your browser.
Request Builder
Build HTTP requests interactively and generate code snippets in multiple languages.
JSON Validator
Validate JSON data and detect syntax errors with detailed error messages and line numbers.
Related Errors
Other common errors in this category:
401 Unauthorized Error
Learn what a 401 Unauthorized error means, common causes, and how to fix authentication failures in your web applications.
403 Forbidden Error
Learn what 403 Forbidden means, how it differs from 401, and how to fix access denied errors in your applications.
404 Not Found Error
Learn what 404 Not Found means, common causes, and how to fix broken links and missing resources on your website or API.
429 Too Many Requests Error
Learn what 429 Too Many Requests means, how rate limiting works, and how to handle or avoid hitting API rate limits.