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

后端 未结 9 1750
礼貌的吻别
礼貌的吻别 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:57

    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.

    Ref: http://en.wikipedia.org/wiki/List_of_HTTP_header_fields

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

    http://en.wikipedia.org/wiki/HTTP_status_code -> 406

    0 讨论(0)
  • 2020-11-22 08:58

    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.

    0 讨论(0)
  • 2020-11-22 08:58

    "Sometimes" this can mean that the server had an internal error, and wanted to respond with an error message (ex: 500 with JSON payload) but since the request headers didn't say it accepted JSON, it returns a 406 instead. Go figure. (in this case: spring boot webapp).

    In which case, your operation did fail. But the failure message was obscured by another.

    0 讨论(0)
提交回复
热议问题