DB / HTTP/Web / 400
WARNING

HTTP/Web Bad Request

The HTTP 400 Bad Request status code indicates that the server cannot or will not process the request due to something perceived as a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).

Common Causes

  • Malformed request syntax (e.g., invalid JSON or XML in the request body).
  • Missing required request parameters or headers.
  • Request entity (body) is too large or in an unsupported format.
  • Invalid URL encoding or query string parameters.

How to Fix

1 Validate Client-Side Request

Ensure the request being sent from the client (browser, app, script) is correctly formatted. Check the URL, headers, and body payload.

BASH
$ # Example using curl to test a POST request with correct JSON curl -X POST https://api.example.com/endpoint \ -H "Content-Type: application/json" \ -d '{"key": "value"}'

2 Check Server-Side Logs

Examine the web server or application logs for more specific details about why the request was rejected. The logs often contain the exact validation error.

BASH
$ # Example for checking Nginx error logs tail -f /var/log/nginx/error.log # Example for checking a Node.js/Express app console output

3 Use a Debugging Proxy

Inspect the raw HTTP request and response using a tool like curl with verbose mode or a proxy like Burp Suite/Charles to identify malformed headers or body content.

BASH
$ curl -v -X POST https://api.example.com/endpoint \ -H "Content-Type: application/json" \ -d '{"key": "value"}'