How to complete the challenge POST /todos vendor XML

This challenge creates a todo with a model-specific +xml request body media type and asks for a negotiated response.

Issue a POST request on the /todos end point to create a todo using Content-Type application/vnd.apichallenges.todo+xml, a normal todo XML body, and a negotiated response.

Basic Instructions

  • Issue a POST request to /todos
  • Add the X-CHALLENGER header to track challenge completion
  • Set Content-Type to application/vnd.apichallenges.todo+xml
  • Set Accept to a supported response format, for example application/json
  • Send a valid <todo> XML body without an id
  • Check that the response status is 201
  • Check the Location header points to the created todo

Try it now

POST /todos with vendor todo XML

Example Request

> POST /todos HTTP/1.1
> Host: apichallenges.com
> X-CHALLENGER: x-challenger-guid
> Content-Type: application/vnd.apichallenges.todo+xml
> Accept: application/json

| <todo>
|   <title>vendor XML todo</title>
|   <doneStatus>true</doneStatus>
|   <description>created with vendor XML</description>
| </todo>

Example Response

< HTTP/1.1 201 Created
< Content-Type: application/json
< Location: todos/123
< X-Challenger: x-challenger-guid

The response body should contain the created todo in the negotiated response format.

Lessons Learned

  • Content-Type: application/vnd.apichallenges.todo+xml tells the API to parse the request body as todo XML.
  • The request Content-Type and response Accept header can name different representations.
  • Vendor +xml request support should be tested separately from generic application/xml.

Suggested Experiments

  • Change Accept to application/vnd.apichallenges.todo+xml and check whether the created todo is returned as vendor XML.
  • Change the request Content-Type to application/problem+xml and confirm it is not treated as a todo body format.
  • Send the same <todo> body with Content-Type: text/xml and compare the create behavior.
Experiment with this endpoint