API 400 Error responses should be in JSON, not HTML

Issue #8910 invalid
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. Jonathan Mooring

    Hi @bendavis78, 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