How to complete the challenge GET /todos (200) q JSON preferred
This challenge reverses the previous preference: both XML and JSON are acceptable, but JSON has the higher quality value.
Issue a GET request on the
/todosend point with anAcceptheader ofapplication/xml;q=0.5, application/json;q=1to receive results in JSON format.
Basic Instructions
- Issue a
GETrequest to/todos - Add the
X-CHALLENGERheader to track challenge completion - Set
Accepttoapplication/xml;q=0.5, application/json;q=1 - Check that the response status is
200 - Check that the response
Content-Typeisapplication/json
Try it now
GET /todos with q-values preferring JSON
Example Request
> GET /todos HTTP/1.1
> Host: apichallenges.com
> X-CHALLENGER: x-challenger-guid
> Accept: application/xml;q=0.5, application/json;q=1
Example Response
< HTTP/1.1 200 OK
< Content-Type: application/json
< X-Challenger: x-challenger-guid
The response body should contain a JSON object with a todos array.
Lessons Learned
application/json;q=1outranksapplication/xml;q=0.5even whenXMLappears first.- Quality values are clearer than relying only on comma order in longer
Acceptheaders. JSONandXMLcan both be acceptable while one format remains the preferred result.
Suggested Experiments
- Swap the order of the two media types without changing the quality values and confirm
application/jsonstill wins. - Set both quality values to
q=1and observe how the server breaks the tie. - Try
Accept: application/problem+json;q=1, application/json;q=0.5and check that the supported fallback is still usable.