Passing array in GET for a REST call

ChrisOdney picture ChrisOdney · Aug 14, 2012 · Viewed 134.4k times · Source

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.

Answer

bryanmac picture bryanmac · Aug 14, 2012

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.