I have a REST API that has been built on top (in front of) a legacy system, to allow 3rd parties of various platforms to interact with the system.
Most of the time, I can define a resource and create a GET and POST/PATCH etc. However, I have a couple of cases where the GET needs to be able to handle potentially a large about of request data, e.g. resource ids, too many for a query parameter.
I need to be able both request data on existing books, and also add new books into the system.
So, I would normally have
GET api/books POST api/books
The problems is I need to be able to support a (potentially) large number if ids to request objects with information about a subset of the books, more than can be included in a url as query parameters. Previously, in a case like this, I have (reluctantly) used a POST so I can send the request parameters in the body.
The problem here, is I already wanted to use the POST to add a new book.
A debate on how to handle this occurred today, and we though we may use
POST api/books (as the GET)
PATCH api/books as the add
Also thought of
POST api/books/get, but this just seems wrong (having a verb in the url).
Has anyone else had to address a similar situation, where you need to use the POST for the GET but still need to "POST" to the resource as well, or perhaps have any suggestions on a better way to do this than what is suggested above?
Thanks in advance for any help!