Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 4802

Should this Json result return a 404 or 200?

$
0
0

I'm trying to make an API sorta loosly based on StackExchange's api results.

So here's 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 do to if the person tries to request a .. um .. product or question or whatever, and the item doesn't exist.

eg..

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

I was thinking I would return a 200 AND the Json above, with the Items property being empty.

The other idea I had was returning that json with the items property empty BUT setting the response http status to 404.

Thoughts / standards ?

I really want to return the json no matter what. Why? the quota's. Even an empty result is still a legit hit to the api service.


Viewing all articles
Browse latest Browse all 4802

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>