406 Not Acceptable Error: What it Means & How to Fix

This error appears when the server returns data in unsupported format

Reading time icon 3 min. read


Readers help support Windows Report. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help Windows Report sustain the editorial team Read more

Key notes

  • To fix 406 Not acceptable in Postman, adjust and add the accept parameter to your request.
  • In some instances, it might be necessary to adjust the header and specify the user agent.

406 Not acceptable error is an HTTP response status code, and it appears if the server can’t properly return the data. Since this is a server-side issue, the client request will fail and the code won’t be executed properly.

This can be a major issue, especially if you’re developing a service that processes various requests daily. Luckily, there are ways to fix this issue, and today we’ll show you how to do that.

What is the Call failed with status code 406 not acceptable error?

The error code 406 appears if the data returned from the server isn’t in a proper format that’s compatible with the client that made the request.

This is a security measure, and if the server doesn’t return the data in the expected format, the code won’t be executed.

How do I fix error 406?

1. Adjust the accept parameter in your code

  1. Open your code.
  2. Locate the line that sends the request and change it like this: profile = personality_insights.profile(profile_text, accept='application/json', content_type='text/plain').get_result()
  3. Save changes.

Note that the accept parameter can only use application/json or text/csv value.

2. Use JSON.stringify

  1. Open your code.
  2. Make sure you add a JSON.stringify function, like this:
    $.ajax({ url: 'http://example.com:9200/incidents/incidents', type: 'POST', data: JSON.stringify(this.incident), dataType: 'json' })
  3. Lastly, save the changes.

Keep in mind that this solution only works if the object is not a properly serialized JSON string.

3. Make sure you specify the user-agent in the header

  1. Open your code editor.
  2. Next, add the request headers and include them like this:
    page_url = 'https://examplepage.com' headers = { 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36', } rawpage = requests.get(page_url,headers=headers)
  3. After doing that, all you need to do is to save the changes.

What is the difference between HTTP 404 and 406?

The HTTP 406 client error response appears when the client sends a legitimate request, but the returned data isn’t in the accepted format.

On the other hand, HTTP error 404 response code is one of the most common client-side errors and probably the most known 4xx error. It appears when the request can’t be processed because the requested data wasn’t found.

406 Not acceptable errors can appear in Java, Angular, and any other language that supports HTTP requests. This issue usually affects developers and not the average Internet users.

To fix it, ensure your client is configured to accept the specific type of data from the server as a response. You can also change server configuration and adjust configuration files so that the server and client both use the supported format.

This is just one of many errors you can encounter, and in the past, we covered HTTP error 431 and HTTP error 413, so don’t miss them if you need more information.

What method did you use to fix the 406 Not acceptable error in Nginx? Share your findings with us in the comments section.

More about the topics: server