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
/todosend point to create a todo using Content-Typeapplication/vnd.apichallenges.todo+xml, a normal todo XML body, and a negotiated response.
Basic Instructions
- Issue a
POSTrequest to/todos - Add the
X-CHALLENGERheader to track challenge completion - Set
Content-Typetoapplication/vnd.apichallenges.todo+xml - Set
Acceptto a supported response format, for exampleapplication/json - Send a valid
<todo>XMLbody without anid - Check that the response status is
201 - Check the
Locationheader 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+xmltells the API to parse the request body as todoXML.- The request
Content-Typeand responseAcceptheader can name different representations. - Vendor
+xmlrequest support should be tested separately from genericapplication/xml.
Suggested Experiments
- Change
Accepttoapplication/vnd.apichallenges.todo+xmland check whether the created todo is returned as vendorXML. - Change the request
Content-Typetoapplication/problem+xmland confirm it is not treated as a todo body format. - Send the same
<todo>body withContent-Type: text/xmland compare the create behavior.