[ckan-discuss] New Zealand CKAN Instance - API errors

Rufus Pollock rufus.pollock at okfn.org
Tue Jul 27 08:22:27 BST 2010

On 26 July 2010 21:37, Glen Barnes <glen at opengovt.org.nz> wrote:
> On 27/07/2010, at 2:17 AM, Rufus Pollock wrote:
> On 23 July 2010 11:11, Glen Barnes <glen at opengovt.org.nz> wrote:
> Posting to /api/2/rest/package/test implies an UPDATE not a CREATE.
> This could be made clearer in the docs I think. Also the error should
> not be a 500 but a 404 (not found) or perhaps 501 Not Implemented.
> Sorry - My text may not have been clear. If you look at the Gist you will
> see that I am posting to the register:
> POST /api/2/rest/package
> This is returning a 500 server error even when it does actually create the
> package sometimes. Friedrich was trying to debug it but I'm not sure where
> he got to. I can do a dump of my DB and send you my conversion code for you
> to test internally if needed.

Apologies, probably misreading at my end. Clearly, something is not
right! We can look further into this -- the painful part is that this
sounds like an intermittent error -- always the worst!

> Any ideas of what could be wrong? Also when it 404's on the API it gives you
> back an HTML 404 page. Shouldn't it give you back a JSON formatted 404
> instead?
> What would you mean by a JSON-formatted 404? {'status': 404}. I
> believe the page does return the right status header (if not that is a
> bug!) and the html page is just a convenience.
> Yes - Any responses from the API should be JSON formatted so you can use the
> information inside the body in your app. Of course the headers say 404 which
> is what you should look at but you should be able to easily see the error
> message as well and you can include an other valid information
> {'status': 404, 'message': 'test package not found'}
> {'status': 503, 'message': 'You are not authorised to create this package.'}
> {'status': nnn, 'message': 'Validation Errors', 'errors':['name cannot be
> blank', 'license code must be an integer']}
> The reason being that screeds of html coming back in the response just makes
> it harder to debug and understand. Having the proper error codes/messages
> means that you can see why your package was not created.
> Hope this makes sense.

This sounds like an obvious improvment to the API for json responses
in case of errors and I think should become a ticket :)


More information about the ckan-discuss mailing list