Clayton A. Alves Clayton A. Alves - 6 months ago 25
JSON Question

What is the standard practice to serve a REST API request, based on requester format?

In my REST API, I have an

endpoint which returns a list of items.

The user of my API may request the items in different formats (json, xml, html).

What is the recommended way to provide a json response:

  • make an
    endpoint ?

  • make an
    endpoint ?

  • or serve it based on user's request header

Answer Source

Serve it based on the Accept request header. This is a standard practice called content type negotiation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download