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
Post a Comment