Should this Json result return 404 or 200?

I am trying to make the sorta API loosly based on ApiExchangeExchange results.

So here is my json output.

{
    "items" : [ ... objects in here .... ]
    "page" : 
    "page_size" :  
    "total_pages" : 
    "total_items_count" :  
    "maximum_quota" : 
    "remaining_quota" : 
}

pretty damn simple.

Now I'm not sure what to do if a person tries to request a product .. a question or question or something else, and the item does not exist.

eg..

{
    "items": []
    ... snipped ....
}

I thought I would return 200 and Json above, with the Items property being empty.

Another idea that I had was to return json with the items empty BUT property, setting the HTTP status of the response to 404.

Thoughts / standards?

I really want to return json, no matter what. What for? quotas. Even an empty result is still a legitimate hit for the api service.

+5
source share
1

-, 400 204:

http://en.wikipedia.org/wiki/List_of_HTTP_status_codes

400

- . [2]

, 400, , .

- JSON. , . StatusMessage " ", .


204

, . [2]

, , , .

* , .

Twitter, , "@JohnDoe", . 204: ", @JohnDoe, , , ", , Twitter.

, , . , , .

+3

All Articles