Take the 2-minute tour ×
Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.

http://api.stackoverflow.com/0.8/users/213464/mentioned?type=jsontext

{
  "error": {
    "code": 404,
    "message": "The server has not found anything matching the Request-URI."
  }
}

Its returning 404 now. I think it should return blank array even if there is no items, and IIRC, it was properly returned blank array few days ago.

or

Am I missing something?

share|improve this question
    
If I'm not mistaken, there was some sort of consensus in another post that in these situations (where there are no items) 404s should be returned, instead of blank arrays. Looks like that was implemented. Previously, some methods returned 404s while others returned blank arrays. –  Maxim Zaslavsky Jun 2 '10 at 7:18
3  
Um, 404 Errors shouldn't do that way, IMHO. –  YOU Jun 2 '10 at 7:28
4  
+100 - i am starting a conversation with kevin regarding this newly introduce 'feature'. I would have to say that it was not thoroughly thought out. Of course empty results should be returned. Of course. If you are requesting a specific resource, a 404 is appropriate, if you are tossing out a net, you should get some fish or no fish, not an oil spill. –  Sky Sanders Jun 2 '10 at 8:15
add comment

2 Answers

up vote 2 down vote accepted

The way it should be...

UsersResult actual = target.GetResult(site);


while (actual.Users.Length > 0 )
{

    target.Parameters.page++;
    actual = target.GetResult();
}

The way it is (as of 10 minutes ago)

try
{

    UsersResult actual = target.GetResult(site);


    while (actual.Users.Length > 0)
    {
        target.Parameters.page++;
        actual = target.GetResult();
    }
}
catch (WebRequestException wre)
{

    if(wre.StatusCode==HttpStatusCode.NotFound)
    {
        // what? did I run out of pages or did I send a bad url?
        // not optimal dev UX and breaks the prototypical paging pattern
    }
    else
    {
        throw;
    }
}

And before anyone suggest that I should just track the count, consider that an item could be removed from the collection while I am paging....

share|improve this answer
    
Thanks code poet. looks fixed now. –  YOU Jun 2 '10 at 8:22
1  
@SMA - yes - 80 greens that were red and are again green confirm. –  Sky Sanders Jun 2 '10 at 8:26
add comment

Probably fixed, now I got following

{
  "total": 0,
  "page": 1,
  "pagesize": 30,
  "comments": []
}
share|improve this answer
    
Yes it does seem to be back to 'normal', all of the tests I just wrote to catch the 404 on every paged result route are failing. which is a good thing. –  Sky Sanders Jun 2 '10 at 8:25
add comment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .