RESTful one or many

by Johan Sjöberg   Last Updated December 18, 2017 09:05 AM

What's a good way to design a RESTful URL pattern to get one and many results by ID ?

One (Response: single item)

/invoices?id=a/b

Many (Response: array of items)

/invoices?id=a/b&id=bar

The above approach looks nice in theory but raises a couple of concerns

  • What (JSON) should be returned if id is omitted, {}, or []
  • What will a client with a List of IDs of size one get back, an array or a single item


Related Questions


Deciding on the correct RESTful URL design

Updated October 20, 2017 22:05 PM