REST status code 204 on paginated result

前端 未结 4 789
灰色年华
灰色年华 2021-01-19 05:28

I am designing a REST like API for paginated data retrieval of a YUI-based client. The REST URL looks like this for a GET request:

/app/catalog/data?startInd         


        
4条回答
  •  日久生厌
    2021-01-19 06:04

    I can't decide whether this is 204 or 404.

    Neither. Just return 200 with an empty result (empty XML document or JSON array, whatever you use). Typically I use REST services with paginated views so along with results page I return total number of records. This will help clients to realize the mistake. But technically it is nothing wrong.

    Use 204 for DELETE operations (there's really no content to return) and for PUT.

    BTW (bold mine):

    if no parameters are given, all data from DB will be dumped

    Believe, you don't want to do this...

提交回复
热议问题