Greg Gum Greg Gum - 4 months ago 21
HTTP Question

What is invalid about this header: Accept: */*; q=0.5; application/json

My app makes a post to an aspnetcore controller.

It is throwing this error message:

FormatException: "Invalid values '*/*; q=0.5; application/json'."

I don't see what is wrong with it.

This is the raw post:

POST /api/attachments/save HTTP/1.1
Host: localhost:4000
Connection: keep-alive
Content-Length: 130897
Pragma: no-cache
Cache-Control: no-cache
Accept: */*; q=0.5; application/json
Origin: http://localhost:4000
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryDBTUPFcCjjuB8Z1p
Referer: http://localhost:4000/
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
Cookie: ai_user=7qQV6|2016-06-29T23:52:02.982Z

How do I resolve this?

Set Set

You should use , instead of ; before application/json:

Accept: */*; q=0.5, application/json

Syntax and semantics of standard HTTP/1.1 header fields are described in Header Field Definitions