Docs Home

API Error 400: Bad Request

An HTTP 400: Bad Request error occurs when the API can't read a request: its body is not valid JSON, or it is missing something the call can't do without.

If you are receiving an HTTP 400: Bad Request error, there are a few possibilities for why it might be occurring:

  • The request body is not valid JSON. This happens whatever the Content-Type header says.
  • The request to create or update a cluster has no body at all. Those calls read their parameters from a JSON body, so an empty body gets the same error as one that isn't valid JSON.
  • The request to destroy a cluster does not pass the cluster's name. A name in the body is only read when the request has a Content-Type: application/json header.

A request refused with a 400 changes nothing.

Example

A request whose body is not valid JSON, or a create or update request with no body, gets this response:

{
  "errors": [
    "The request body does not appear to be valid JSON."
  ],
  "status": 400
}

A request to destroy a cluster without its name gets this one:

{
  "errors": [
    "Pass the name of the cluster as `name`."
  ],
  "status": 400
}

The "status": 400 key indicates the HTTP 400: Bad Request error.

Troubleshooting

Check the body your client actually sends, for example with curl's -v flag, and run it through a JSON validator. Common causes are a trailing comma, single quotes instead of double quotes, and a body built by string concatenation that isn't escaped.

Send a Content-Type: application/json header with every request that has a body. For a DELETE request, also check that your HTTP client sends the body at all: some drop the body of a DELETE. If yours does, pass name in the query string instead.

If all else fails, you can always contact support and we will be glad to assist.

Ready to power your search with AI?

Launch a fully managed Elasticsearch or OpenSearch cluster, with built-in vector search and AI capabilities.

Create an AI Ready Search Cluster
Calming Bonsai waves