REST - Tradeoffs between content negotiation via Accept header versus extensions

Posted by Brandon Linton on Programmers See other posts from Programmers or by Brandon Linton
Published on 2012-03-14T02:50:53Z Indexed on 2012/10/18 17:24 UTC
Read the original article Hit count: 302

Filed under:
|
|
|

I'm working through designing a RESTful API. We know we want to return JSON and XML for any given resource. I had been thinking we would do something like this:

GET /api/something?param1=value1
Accept:  application/xml (or application/json)

However, someone tossed out using extensions for this, like so:

GET /api/something.xml?parm1=value1 (or /api/something.json?param1=value1)

What are the tradeoffs with these approaches? Is it best to rely on the accept header when an extension isn't specified, but honor extensions when specified? Is there a drawback to that approach?

© Programmers or respective owner

Related posts about architecture

Related posts about web-services