How to complete the challenge GET /todos (406) q rejects all
This challenge sends an Accept header that names supported formats but explicitly rejects both of them.
Issue a GET request on the
/todosend point with anAcceptheader ofapplication/json;q=0, application/xml;q=0to receive 406 'NOT ACCEPTABLE' status code.
Basic Instructions
- Issue a
GETrequest to/todos - Add the
X-CHALLENGERheader to track challenge completion - Set
Accepttoapplication/json;q=0, application/xml;q=0 - Check that the response status is
406 - Check that the error response is returned in a format your client can inspect
Try it now
GET /todos while rejecting JSON and XML
Example Request
> GET /todos HTTP/1.1
> Host: apichallenges.com
> X-CHALLENGER: x-challenger-guid
> Accept: application/json;q=0, application/xml;q=0
Example Response
< HTTP/1.1 406 Not Acceptable
< Content-Type: application/json
< X-Challenger: x-challenger-guid
The error body should explain that no acceptable response type was available.
Lessons Learned
q=0excludes a media type, even when the API normally supports that representation.- Listing only excluded
JSONandXMLchoices leaves no normal todo representation to return. - A
406response can be the correct result when the client rules out every supported format.
Suggested Experiments
- Change
application/json;q=0toapplication/json;q=0.1and confirm that the request can succeed. - Add
*/*;q=0.1and observe whether the server can choose a default fallback. - Compare this with an unsupported type such as
application/gzip, where no supported media type is named.