In each representation, include a self link to the resource and include identifiers for each of the application domain entities that make up resource.
And here's a sample:
{
"name":"John",
"id":"urn:example:user:1234",
"link":{
"rel : " self",
"href":"http://www.example.org/person/john"
},
"address":{
"id":"urn:example:address:4567",
"link":{
"rel : " self",
"href":"http://www.example.org/person/john/address"
}
}
}
--
You received this message because you are subscribed to the Google Groups "API Craft" group.
To unsubscribe from this group, send email to api-craft+...@googlegroups.com.
Visit this group at http://groups.google.com/group/api-craft?hl=en.
--
From the atom rfc:
"3. The value "self" signifies that the IRI in the value of the href
attribute identifies a resource equivalent to the containing
element."
I didn't find a compelling use case for self yet. If I understand it correctly, the href is not guaranteed to remain stable, so it doesn't safely identify an element for future sessions. And I did not see a case where it really made sense to retrieve a resource as a standalone representation which I already had in the current resource, where it might be part of a collection or attached to another object. It is not equivalent to home, since self must not point to a different resource. Has anyone actually used self for something in a client? I know atom requires it as a SHOULD and I am all for adhering to that, but what can a client really do with it?
Best regards,
Dietrich
--
--
2013/1/4 Glenn Block <glenn...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "API Craft" group.
To unsubscribe from this group, send email to api-craft+...@googlegroups.com.
Visit this group at http://groups.google.com/group/api-craft?hl=en.
as I said, I'm all for including it, it is a SHOULD after all. Constructing urls in the client from previously known url templates and using server ids for that is certainly not an option, and self makes that clear.
But what do the clients actually do with self? Ok, they could use it for bookmarking if they update bookmarks upon a 301. However, that is just a possible use case, I never really did that. Are there clients implementing use cases on the client side which *require* self?
--
Thank you for the eye-opener. I admit I did not consider other methods than GET for self. :-)
Best regards
Dietrich
--
--
You received this message because you are subscribed to the Google Groups "API Craft" group.
To unsubscribe from this group, send email to api-craft+unsubscribe@googlegroups.com.
M
--
You received this message because you are subscribed to the Google Groups "API Craft" group.
To unsubscribe from this group, send email to api-craft+...@googlegroups.com.
M
- Client parsing libraries can deal purely in terms of JSON and do not
need access to some data structure representing the response/request.
- The way you represent a resource is consistent whether embedded or
not, and this is good because it's a simpler model and makes stuff
like server-side or edge-side includes possible.
there are probably other reasons they're just not coming to mind right now
--