0
votes

I'm trying to understand the difference between using a comma versus semicolon to delimited multiple content type in one string added to the restSharp request header.

Example:

request.AddHeader("Accept", acceptContentType);

with acceptContentType being the following:

application/json;odata=verbose

(this works as expected)

application/json,odata=verbose

(fails with code 400: The HTTP header field "Accept" with value "application/json,odata=verbose" could not be parsed.)

and

application/json;application/xml

(this fails with code 400. error: The HTTP header field "Accept" with value "application/json;application/xml" could not be parsed.)

application/json,application/xml

(this returns data content type as json

application/xml,application/json

(this returns data content type as xml

Is there a standard to follow or is it all dependant on the server side of how it handles the incoming header?

2

2 Answers

0
votes

Apologies, I see where I made a mistake. swagger defeintion will look like this

"produces": [ "application/json;odata=verbose", "application/xml" ],

and not

"produces": [ "application/json", "odata=verbose", "application/xml" ]

so comma should be the separator between types and semicolon for extending the type

application/json;odata=verbose,application/xml

-1
votes

One is media types Group, separated by comma, like application/json,application/xml Another is Parameters Group, like odata=verbose,odata2=verbose2 if put 2 together, then will be like application/json,application/xml;odata=verbose,odata2=verbose2