What is “406-Not Acceptable Response” in HTTP? [json]


406 Not Acceptable The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.

406 happens when the server cannot respond with the accept-header specified in the request. In your case it seems application/json for the response may not be acceptable to the server.


In my Ruby on Rails application I tried to upload an image through the POSTMAN REST client in Base64 format. When I POST the image I am getting a 406 Not Acceptable Response. When I checked my database, the image was there and was successfully saved.

What is the reason for this error, is there anything I need to specify in my header?

My request:

URL --- http://localhost:3000/exercises.json


Content-Type  -  application/json

Raw data:

    "exercise": {
        "subbodypart_ids": [
        "name": "Exercise14"
    "image_file_name": "Pressurebar Above.jpg",
    "image":"******base64 Format*******"

Spring MVC @ResponseBody return a List

Yes, when your controller method in annotated with @ResponseBody, Spring transforms returned data into JSON.

During 2 days, i tried many ways : - responseEntity - httpheaders - XML etc...

For a JSON (default behavior), the project need a library with all Spring library. Here the library to declare in Maven project.


Without this library, i have an Error (406).

Thank you anyway for all your answers & advices.

This is the curl command I use to post json data:

curl http://IP:PORT/my/path/to/endpoint -H 'Content-type:application/json' -d '[{...json data...}]'

This is equivalent to the above curl command with C#:

var url = "http://IP:PORT/my/path/to/endpoint";
var jsonData = "[{...json data...}]";

using (var client = new WebClient())
    client.Headers.Add("content-type", "application/json");
    var response = client.UploadString(url, jsonData);

PHP/Apache Error:406 Not Acceptable

Your website is generating error if any user input item is starting with either http:// or https:// .

When I try with a link starting with http:// I got a 406 Not Acceptable :


It is fine when I try this :


You've mentioned that you are having problem if it is more than one link , but when I try with two links like below , it is being fine :


However either you could find and fix the issue which might be specific to your server configuration or you could try a work around .

I am not sure if this workaround helps , but considering that http:// or https:// are creating the issue , what I am thinking is to remove the http:// and https:// from user input . First you might want to try changing <input type="url" to <input type="text" so that URL format is not enforced . Then you could use Javascript to remove occurrences of http:// and https:// from the user input in the form before submitting to server . Additionally you could remove these from the data before populating the form values .

Hope this helps .

Regex : How to remove 'http://' from a URL in JavaScript

I have been having this problem for a while and only once in a while, so it was hard to identify.

However, after some testing I have found the mistake in my case. It may be not in yours, but if anyone is having 406 Not Acceptable error it is worth a shot.

In my case that error occured whenever posted data had 'shell:' in it, which as I would guess is interpreted wrong and error is thrown. Solution for me was to replace that string before posting it.