Rectangle 27 0

json What is "406 Not Acceptable Response" in HTTP?


If you happened to run two different projects on the same port, the browser might reference a cookie from a different localhost session.

This has happened to me...tripped me up for a minute. Looking in browser > Developer Mode > Network showed it.

You can also receive a 406 response when invalid cookies are stored or referenced in the browser - for example, when running a Rails server in Dev mode locally.

Note
Rectangle 27 0

json What is "406 Not Acceptable Response" in HTTP?


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 don't have remove the header, you will have to supply a different one which is acceptable to the server. en.wikipedia.org/wiki/

if i remove the header i am getting an error........

Note
Rectangle 27 0

json What is "406 Not Acceptable Response" in HTTP?


  • Find out the response (content type) returned by Service.
  • Provide this (content type) in your request Accept header.

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

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

Your operation did not fail.

Note
Rectangle 27 0

json What is "406 Not Acceptable Response" in HTTP?


Content-Type: application/x-www-form-urlencoded
Note
Rectangle 27 0

json What is "406 Not Acceptable Response" in HTTP?


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

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:

Note