0

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
per_jansson
  • 2,103
  • 4
  • 29
  • 46

3 Answers3

0

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.

Eric Stein
  • 13,209
  • 3
  • 37
  • 52
0

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.

cjungel
  • 3,701
  • 1
  • 25
  • 19
0

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.

Community
  • 1
  • 1
Randy
  • 729
  • 5
  • 14