[ckan-dev] Confused on response['success'] and HTTP status codes with empty results

Daniel Graziotin dgraziotin at task3.cc
Thu Mar 28 09:12:39 UTC 2013


Hi,
I understand that the new API is abandoning the idea of a RESTful service in favor of a RPC-like architecture over HTTP requests.
 I am fine with this, just take this in mind in what follows.

Given that CKAN Action API is not RESTful: when there are no results, why do 
- some methods return HTTP 200, response['success']: true and response['results']:[]
- some other methods return HTTP 400, response['success']: false and a not found error

Example:

Searching for tags with zero results
---
http --json http://beta.ckan.org/api/action/tag_search q=LOL

HTTP/1.1 200 OK
[...]

{
    "help": [...],
        "result": {
        "count": 0,
        "results": []
    },
    "success": true
}
---

Trying to retrieve a non-existing tag by id
---
http --json http://beta.ckan.org/api/action/tag_show id=12345
HTTP/1.1 404 Not Found
[...]

{
    "error": {
        "__type": "Not Found Error",
        "message": "Not found"
    },
    "help": [...]
    "success": false
}
---

Given that this is not RESTful, why isn't the second one a successful request - e.g., a valid request - however with no results?
If this was a RESTful API it would make sense. However, in that case I would do something like GET /api/tags/12345 and expect a HTTP 404 status code when such result was not existing.

Not criticizing the architectural choices here. I am just trying to do some sense making in order to build a better libckan.

Cheers,
--Daniel Graziotin






More information about the ckan-dev mailing list