api - RESTful - Different URI of same resource to get different forms of same resource -


i'm pushed peculiar situation i'm not able decide wrong , right.

i've resource called invoice. json or xml representation use below uri

somedomain.com/inovices/{invoicenumber} - invoice number numeric accept: application/xml 

when want pdf of same resource use below uri:

somedomain.com/inovices/{invoicenumber} - invoice number numeric accept: application/pdf 

both above url's served authenticated requests. want support same resource using guid unauthenticated requests, hence want use below url

somedomain.com/inovices/{guid} accept: application/pdf 

above url permanent url , can access url number of times. confusion whether providing url above restful or not. because in 1 url i'm using invoice number numeric , permanent url i'm replacing guid.

reason why felt wrong same resource represented 2 different uri's (number , guid) though returning same resource. or assumption wrong? against rest cosntraint i'm not able understand?

there's no problem @ different uris point @ same resource. it's not ok, it's recommended, if add value user.

think of these examples:

get /api/users/543 /api/users/bob-marley 

or, does:

get /questions/16637720/restful-different-uri-of-same-resource-to-get-different-forms-of-same-resource /q/16637720/1118323 

there similar examples everywhere. may want add "unnessecary" information if it's going users, or seo, , still keep short version available. or imagine senarios, want add more ways of accessing resources without breaking existing ones. sounds quite common me , don't break rules having more 1 uri same resource.

if worried user might think 2 resources different since used different uri, can have 1 uri redirect other, make explicit it's same resource (as when hit short link, or link without thread heading).

here relevant answer.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -