Ticket #377 (closed enhancement: wontfix)

Opened 4 years ago

Last modified 2 years ago

API Should return JSON in all cases

Reported by: glen@… Owned by:
Priority: awaiting triage Milestone: ckan-future
Component: ckan Keywords:
Cc: Repository: ckan
Theme: none

Description

When the API returns any response it should always retunr JSON. For example a 404 response should return something like

{'status': 404, 'message': 'package somename not found'}

When errors are encountered when creating a package:

{'status': nnn, 'message': 'Validation Errors', 'errors':['description':'name cannot be
blank', 'description':'license code must be an integer']}

Not authorised:

{'status': 503, 'message': 'You are not authorised to create this package.'}

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.

Change History

comment:1 Changed 4 years ago by johnbywater

Thanks a lot! I totally agree and have already started working on this. For example, try pointing your browser to http://ckan.net/api/search/revision (ie without any arguments). Also, there is probably a lot less HTML than there was, since the errors are not handled as if it was an error within the "Web" user interface. At any rate, perhaps we could work through the error cases, filling in the tests as we go? I think it's just unworked ground, rather than anything deliberate. :-)

comment:2 Changed 3 years ago by thejimmyg

  • Owner set to thejimmyg

comment:3 Changed 2 years ago by ross

  • Owner thejimmyg deleted
  • Repository set to ckan
  • Theme set to none
  • Status changed from new to assigned

We have another ticket for fixing the API

comment:4 Changed 2 years ago by ross

  • Status changed from assigned to closed
  • Resolution set to wontfix
  • Milestone set to ckan-future
Note: See TracTickets for help on using tickets.