http http-response-codes http-status-code-406 json rest

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


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*******"



Your operation did not fail.

Your backend service is saying that the response type it is returning is not provided in the Accept HTTP header in your Client request.


  1. Find out the response (content type) returned by Service.
  2. Provide this (content type) in your request Accept header. -> 406


  • 15

    Hi, When you say “Find out the response (content type) returned by the service”? How might I check this? I am returning json from a php file so Im presuming the content type will be json (or do i need to specify this in the headers of the php file?) also I provided this content type in my request header like so ‘Accept’:’application/json’. would this be correct? thanks

    – Sarah

    Mar 4, 2017 at 19:34


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.



You mentioned you’re using Ruby on Rails as a backend. You didn’t post the code for the relevant method, but my guess is that it looks something like this:

def create
  post = Post.create params[:post]
  respond_to do |format|
    format.json { render :json => post }

Change it to:

def create
  post = Post.create params[:post])
  render :json => post

And it will solve your problem. It worked for me 🙂