You can support this site from as little as $1 a month on Patreon.

The support pays for site hosting and the expansion of this content.

In addition, Patreon Supporters gain access to exclusive online video training courses and ebooks.

Join Now

How to complete the challenge GET /todos/export (200) HTML download

This challenge asks for an HTML export of the todos. The important part is not only the HTML body; the response should also include a Content-Disposition header that marks it as a downloadable attachment.

GET /todos/export HTML download

Issue a GET request on the /todos/export?format=html end point and receive an HTML response with a Content-Disposition header for todos.html.

  • GET asks the API to return the todos.
  • /todos/export uses a format query parameter to choose the representation.
  • format=html requests an HTML representation.
  • Content-Disposition: attachment tells the client this can be treated as a file download.
  • filename="todos.html" suggests the download filename.
  • Add the X-CHALLENGER header to track progress.

Basic Instructions

  • Issue a GET request to end point "/todos/export?format=html"
    • if running locally that endpoint would be
      • https://apichallenges.eviltester.com/todos/export?format=html
  • The request should have an X-CHALLENGER header to track challenge completion.
  • The response status code should be 200.
  • Check the Content-Type response header starts with text/html.
  • Check the Content-Disposition response header is attachment; filename="todos.html".
  • Check the response body contains an HTML table.

The format query parameter controls the export type for this endpoint. You can send an Accept header, but this challenge is solved by requesting format=html and checking the response headers.

Try it now

Example Request

> GET /todos/export?format=html HTTP/1.1
> Host: apichallenges.eviltester.com
> User-Agent: rest-client
> X-CHALLENGER: x-challenger-guid
> Accept: text/html

Example Response

< HTTP/1.1 200 OK
< Content-Type: text/html
< Content-Disposition: attachment; filename="todos.html"
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Headers: *
< X-Challenger: x-challenger-guid

Example Response body:

<table>
  <tr><th>id</th><th>title</th><th>doneStatus</th><th>description</th></tr>
  <tr><td>1</td><td>scan paperwork</td><td>false</td><td></td></tr>
</table>

Extra Experiment

Open todos.html in a browser or save the response body as todos.html. The same response can be inspected as data or treated as a downloadable HTML file because of the response headers.

Other format parameter values to try include json, xml, csv, text, ndjson, jsonl, json-seq, tsv, and tab-delimited. The text aliases txt and plain, JSON sequence alias jsonseq, and tab aliases tab, tabs, and tab-separated are also supported.