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

后端 未结 9 1773
礼貌的吻别
礼貌的吻别 2020-11-22 08:20

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 Resp

9条回答
  •  难免孤独
    2020-11-22 08:39

    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 }
      end
    end
    

    Change it to:

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

    And it will solve your problem. It worked for me :)

提交回复
热议问题