Is it recommended or not to use explicit path variables or not in REST when drilling down in a resource? E.g:
GET http://myhost.com/customers/123/analyses/456/reports/789
or
GET http://myhost.com/customers/123/456/789
Is it recommended or not to use explicit path variables or not in REST when drilling down in a resource? E.g:
GET http://myhost.com/customers/123/analyses/456/reports/789
or
GET http://myhost.com/customers/123/456/789
REST doesn't have anything specific to say about it, but it's considered better to use explicit variables for readability. That being said, you might want to consider not nesting to three levels if you can avoid it.
Both options are ok as long as it makes sense from your application's standpoint and you are describing resources (level 2 according to Richardson Maturity Model).
Personally I would prefer the first option as it it more human readable.
From what I have read, you would do something like:
From customer at
GET http://myhost.com/customers/123
would have links to his/her reports as
GET http://myhost.com/analyses?customer=123
which would return data from
GET http://myhost.com/customers/analyses/456
it would have links to child reports in its data as
GET http://myhost.com/reports?analysis=456
which would return your report at
GET http://myhost.com/report/789
This is partially based on this link: RESTful URL design for search and on reading Fielding dissertation.