What is the appropriate use case in the REST API to use? Question Estimate of parameters?
To this REST tutorial site,
When, if ever, it is appropriate to put something like
http://dev.m.gatech.edu/developer/USER_NAME/api/WIDGET_NAME/test?query=someparam
instead
http://dev.m.gatech.edu/developer/USER_NAME/api/WIDGET_NAME/test/someparam
or
http://dev.m.gatech.edu/developer/USER_NAME/api/WIDGET_NAME/test/someparam/var1/param/var2/param
?
I've seen various things on SO.
source to share
All cases when you make a GET request and have to pass some parameters should look like: param = value.
So the first link is at the top, are they just wrong? Someone you can trust these days :).
No, they are not wrong. Take this example from this site
GET http://www.example.com/customers/33245/orders
Here customers
, 33245
and orders
not request parameters, they are resource endpoints or uri nodes as they call them on your restapitutorial.com
If you do
GET http://www.example.com/customers
you get all customers GET http://www.example.com/customers/33245
you get a customer 33245 GET http://www.example.com/customers/33245/orders
you get a customer 33245 orders
They all return 0 or more resources. If you applied a query to, for example, the first one and you would like to GET all clients with John as their name, you would do this
GET http://www.example.com/customers?firstname=John
In the last example in your question, it will be written as GET http://www.example.com/customers/firstname/john
, and is incorrect in terms of rest. There is no customer name "firstname" and no resource firstname "john".
There are clients whose name is "john" and you will get them with
GET http://www.example.com/customers?firstname=John
source to share