Skip to content

Some API responses are text/plain, rather than JSON #867

@algernon

Description

@algernon

While writing some tests for my library, I stumbled upon another minor inconsistency: trying to retrieve a non-existent post will always return a response in text/plain, whether authenticated or not.

Reproduction:

❯ curl -i http://localhost:8080/api/posts/0 -H "content-type: application/json"
HTTP/1.1 404 Not Found
Cache-Control: public, max-age=604800, immutable
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Thu, 09 Nov 2023 18:19:02 GMT
Content-Length: 19

404 page not found

Same thing happens when I try to post an update, or delete a non-existing post: the response is in text/plain. Looks like the entire /api/posts/{id} endpoint returns text/plain when the id doesn't exist, rather than the usual json.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions