When you see this status
- Request body is not valid JSON
- Missing required query parameters
- Invalid data types in request payload
- Malformed URL or headers
Common causes
- Client sends malformed request syntax
- Invalid request headers or payload
- Missing required parameters
- Syntax errors in query strings
How to debug it
- Validate request payload with JSON schema
- Check server logs for malformed input
- Inspect client-generated request
- Test with minimal payload to isolate issue
Return this code in your framework
Express (Node.js)
res.status(400).json({ error: 'Bad Request' });
FastAPI (Python)
return JSONResponse(status_code=400, content={"error": "Bad Request"})
NestJS
@Get() @HttpCode(400) getBadRequest() { return { error: 'Bad Request' }; }
Go (net/http)
w.WriteHeader(http.StatusBadRequest); w.Write([]byte(`{"error":"Bad Request"}`))
About HTTP 400
HTTP status code 400 Bad Request is part of the
4xx Client Error family. The server cannot process the request due to client-side errors like malformed syntax. Understanding it is essential for
backend engineers, API designers, and anyone debugging integrations between services.
The Qaynaq Labs HTTP Status Code Explainer covers all standard codes with practical guidance:
what triggers them, how to debug them in production, and exactly how to return them from common
frameworks. Each code page is hand-curated and verified.