2

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?

3
  • 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. Jun 2, 2010 at 7:18
  • 3
    Um, 404 Errors shouldn't do that way, IMHO.
    – YOU
    Jun 2, 2010 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. Jun 2, 2010 at 8:15

2 Answers 2

2

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....

1
  • 1
    @SMA - yes - 80 greens that were red and are again green confirm. Jun 2, 2010 at 8:26
0

Probably fixed, now I got following

{
  "total": 0,
  "page": 1,
  "pagesize": 30,
  "comments": []
}
1
  • 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. Jun 2, 2010 at 8:25

You must log in to answer this question.

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