HTTP Error 400 = “Bad Request”
The server could not understand or process the request because the request is invalid.
Common causes
- Invalid URL or query parameters
- Missing required fields in API/body
- Malformed JSON/XML
- Invalid headers
- File upload too large or unsupported
- Corrupted cookies/cache
- Wrong request method (
GETvsPOST) - Invalid authentication format
Fixes for users
- Refresh the page
- Clear browser cache/cookies
- Check the URL carefully
- Try another browser/device
- Re-login if authentication expired
Fixes for developers
- Validate request body
Bad JSON example
json id=”tpfj8g”
{
“name”: “John”,
}
Correct JSON
json id=”kff6hz”
{
“name”: “John”
}
- Set correct headers
http id=”vjlwmr”
Content-Type: application/json
Accept: application/json
- Laravel validation example
php id=”jlwm8r”
$request->validate([
’email’ => ‘required|email’,
‘password’ => ‘required’
]);
- Node.js Express example
js id=”6r7w2z”
app.use(express.json());
- Check request method
php id=”9ucnjf”
Route::post(‘/login’, [AuthController::class, ‘login’]);
Calling this route with GET may return 400.
API debugging checklist
- Verify endpoint URL
- Verify request payload
- Check headers
- Check authentication token
- Inspect server logs
- Test with Postman or curl