Should JSON representation of REST resources use URIs for related resources? -


is best practice of using uris in json (or xml) representation of rest resources, example

for example resource has list of attachments, every attachment has id can used retrieve using url http://myserver.com/resources/attachments/:

{     filename: "screenshot.png"     contenttype: "application/octet-stream"     id: 52004 } 

should add uri element like

{     filename: "screenshot.png"     contenttype: "application/octet-stream"     id: 52004     uri: /resources/attachments/52004 } 

yes, think should include link each item in collection. api not restful (and more importantly, not useful) without links. if think human client rather have link instructions on how request item id, same applies non-human client. should give client idea of how item relates current resource providing link relationship:

link : { uri: "/resources/attachments/52004", rel: "/rels/file-attachment" } 

john


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -