i have a case where user can filter and download multiple pdf documents merged into single file.
The client should display an error message when no document's meets the filter, and ask for confirmation when there are many documents because it might take a while to process them (let's say the confirmation should trigger at 10 documents).
For now i've implemented it as described below, but it just seems off.
Request: GET /foo?limit=10
The results are:
- Everything is correct: status
200 OK
, the body would contain download link. - No documents found that are matching the filter: status
404 NOT FOUND
, empty body - Found more than 10 (requested limit) documents that are matching the filter: honestly no idea what the status should be, for now i am returning
429 TOO_MANY_REQUESTS
but it's not right. The body contain the amount of documents so the user can either abort the operation or create new request with higher limit.
Im sure that im missing something important, i have not enough experience in the field. What is the right way of handling this?
Other solutions that i've been thinking about:
- using custom http codes, but i've come to a conclusion that it's probably a bad idea (even if they are free now, i don't know whether they might be used as official http codes in a year or ten years from now, besides, it feels like an overkill).
- each of these situations resulting in
200 OK
and give more info in the request body