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 /todos end point with an Accept header of application/xml;q=0.5, application/json;q=1 to receive results in JSON format.

Basic Instructions

  • Issue a GET request to /todos
  • Add the X-CHALLENGER header to track challenge completion
  • Set Accept to application/xml;q=0.5, application/json;q=1
  • Check that the response status is 200
  • Check that the response Content-Type is application/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=1 outranks application/xml;q=0.5 even when XML appears first.
  • Quality values are clearer than relying only on comma order in longer Accept headers.
  • JSON and XML can 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/json still wins.
  • Set both quality values to q=1 and observe how the server breaks the tie.
  • Try Accept: application/problem+json;q=1, application/json;q=0.5 and check that the supported fallback is still usable.
Experiment with this endpoint