restrestful-urlrestful-architecture

Passing array in GET for a REST call


I have a url to fetch appointments for a user like this:

/user/:userId/appointments

How should the url look like if I want to get appointments for multiple users?

should it be:

/appointments?users=1d1,1d2..

Thanks, Chris.


Solution

  • Collections are a resource so /appointments is fine as the resource.

    Collections also typically offer filters via the querystring which is essentially what users=id1,id2... is.

    So,

    /appointments?users=id1,id2 
    

    is fine as a filtered RESTful resource.