Click here to Skip to main content
15,890,717 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear experts
I'm very new with REST and reading a lot about it. At the moment I have a trivial question.
Lets say we have the entity "suppliers"
suppliers
  SupplierId
  SupplierName
  ...
To retrive a list of suppliers the REST api supports
GET /suppliers

Now, to retrive a specific supplier I see two possibilites:
a.) GET /suppliers/{Id}
b.) GET /suppliers?Id={Id}

My impression is that usually one will use a.) therefore my question: What are the arguments not to use b.) ?

Thank you very much in advance for some hints.

What I have tried:

Reading a lot about REST................
Posted
Updated 26-Jan-19 9:25am
Comments
[no name] 24-May-19 13:39pm    
works?

1 solution

If possible use A, but if you want to apply one or more filters, use B.
See article here: REST: Good Practices for API Design – HashmapInc – Medium[^]

Also see: RESTful Services Quick Tips[^]
Quote:
Use identifiers in your URLs instead of in the query-string. Using URL query-string parameters is fantastic for filtering, but not for resource names
If you are looking for a REST framework, take a look at: https://www.slant.co/topics/1397/~web-frameworks-to-create-a-web-rest-api[^]
 
Share this answer
 
v3
Comments
[no name] 26-Jan-19 15:32pm    
"one or more filters": _one_ would be ?Id={Id} :-)
RickZeeland 26-Jan-19 15:42pm    
Yep, you are free to do whatever you want, but it's not considered good practice ...
[no name] 26-Jan-19 15:45pm    
Thanks for this. A 5
RickZeeland 26-Jan-19 15:51pm    
I REST my case :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900