I'm writing a paper about implementing a REST service for a university's research papers and I have a small problem understanding the relationship between URIs and Resources.
It says, that a resource may have one URI or many. So here is my problem. I want to make this service very easy to use and to get around the information: a resource should be accessed from different entrypoints, but this will go against the concept, that every "URI designates exactly one resource".
So my question is if the following is it or is it not in accordance with REST the following:
I want to expose information about a research publication (let's say a peer reviewed).
This can be accessed by this URI: UNIVERSITY/publications/{my_publication}.
But since this paper is written by a researcher that works at the let's say Social Science Faculty, it will also make sense that the publication has this URI: UNIVERSITY/faculties/social_science/publications/{my_publication}.
Further more, as the service also expose all researchers working at the university (e.g. UNIVERSITY/researchers/{my_researcher}) it will also make sense that the publication can be named as UNIVERSITY/researchers/{my_researcher}/publications/{my_publication}.
This could go on with multiple usecases, but you get the idea.
Is this in accordance with REST or not?
Can I keep this and solve the dilemma by sending a response code 303("See also") along with the canonical URI (that will be UNIVERSITY/publications/{my_publication}).
Thank you in advance!
It says, that a resource may have one URI or many. So here is my problem. I want to make this service very easy to use and to get around the information: a resource should be accessed from different entrypoints, but this will go against the concept, that every "URI designates exactly one resource"
No it doesn't. "Every finger belongs to exactly one hand" does not imply "every hand has exactly one finger". "Every URI designates exactly one resource" does not imply "every resource is designated by exactly one URI".
That said, a redirect to a canonical URI would improve some use cases ( such a two users bookmarking the same paper on delicious, having arrived there from different queries ).
You also seem to be thinking about constructing URLs via hierarchic patterns, rather than anything about REST. REST applications use "hypertext as the engine of application state". The form of the URI is irrelevant, what matters is that it is navigable from the representation returned at the application's entry point. Fielding (the inventor of REST) makes this clear in his blog REST APIs must be hypertext-driven as an anti-pattern causing coupling between client and server:
A REST API must not define fixed resource names or hierarchies (an obvious coupling of client and server).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With