Answer the question
In order to leave comments, you need to log in
How to correctly specify the response type for the REST API?
Drinking restful service in Jersey. One of the methods returns a list of (for example) employees in one of the formats (xml, json, binary etc).
Which method of forming the resource name is more correct to choose, given the chosen format?
With content-type:
-X GET -H "Content-Type:text/xml" -G http://super-rest/employees
-X GET -H "Content-Type:application/json" -G http://super-rest/employees
-X GET -H "Content-Type:application/octet-stream" -G http://super-rest/employees
-X -G http://super-rest/employees?type=xml
-X -G http://super-rest/employees?type=json
-X -G http://super-rest/employees?type=binary
Answer the question
In order to leave comments, you need to log in
So there is a special Accept header, in which the client specifies which formats it supports.
Ie:
- Accept: application/json
- Accept: text/xml
- Accept: text/plain, text/xml
This is the most correct option in terms of HTTP, but for convenience I would use the 2nd option (passing to URL).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question