Issue #8910 invalid

API 400 Error responses should be in JSON, not HTML

Ben Davis
created an issue

400 error responses are currently returned as difficult-to-parse HTML:

<ul class="errorlist">
    <ul class="errorlist"><li>You already have a repository with this name.</li></ul>

It stands to reason that json should be the default response type, since the response type for successful API calls is also json.

At the very least, the API should respect the Accept: header in the request. For example, if I send a request with the header "Accept: application/json", the API should know I want json and return that.

    "errorlist": [
        {"name": ["You already have a repository with that name"]}

Comments (6)

  1. Jon Mooring staff

    Hi Ben Davis, thanks for the report. All of our v2 APIs should send JSON error responses. In order to prevent breaking compatibility, we chose not to make the same changes to our v1 APIs. Is it the case that you're using a v1 API?

  2. Log in to comment