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-Typeheader 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. Anamein the body is only read when the request has aContent-Type: application/jsonheader.
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:
A request to destroy a cluster without its name gets this one:
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.