[Developers] minor change in search api behavior (empty result set will no longer be an error)

David Flanagan david at davidflanagan.com
Thu Jul 17 23:10:44 UTC 2008


I've always been told that the correct way to test for success with 
Metaweb services is not to test for a code equal to /api/status/ok, but 
to check for a code that begins with "/api/status/ok".

It occurs to me that this is a case where it might be useful to return a 
code /api/status/ok/empty.  It still indicates success, but allows it to 
be special-cased, when desired.

(And those of us who write documentation saying "you have to do a prefix 
match on the code" can give an example that proves the point!)

	David

brendan wrote:
> Hi all,
> 
> This change is no likely to affect any apps/scripts out there, but here 
> goes:
> 
> Currently, if you make a search request and the service finds nothing, 
> it comes back as an error.  e.g.:
> 
> http://freebase.com/api/service/search?prefix=insx&type=/music/artist&type_strict=all 
> <http://freebase.com/api/service/search?prefix=insx&type=/music/artist&type_strict=all> 
> 
> {
> "status": "200 OK",
> "code": "/api/status/error",
> "messages": [
>  {
>    "message": "No search results found",
>    "code": "/api/status/error/search/empty"
>  }
> ],
> "result": []
> }
> 
> In the coming weeks this will change.  The expected response for an 
> empty result will be:
> 
> { 
>   "status": "200 OK", 
>   "code": "/api/status/ok", 
>   "messages": [ 
>     { 
>       "message": "No search results found" 
>     } 
>   ], 
>   "result": [] 
> }
> 
> This response just seems more sensible, particularly given that the 
> service allows the user to request a very constrained result (strict=all 
> means results must match the given type parameter value)
> 
> If your code has error handling for this "no results" case, you might 
> want to make sure this change won't break things.
> 
> Let me know if you have any questions/concerns.
> 
> Brendan
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Developers mailing list
> Developers at freebase.com
> http://lists.freebase.com/mailman/listinfo/developers



More information about the Developers mailing list