[Koha-bugs] [Bug 29595] New: missing Content-Type / HTTP 415 check for POST requests to /api/v1/patrons
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Mon Nov 29 20:43:52 CET 2021
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29595
Bug ID: 29595
Summary: missing Content-Type / HTTP 415 check for POST
requests to /api/v1/patrons
Change sponsored?: ---
Product: Koha
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: trivial
Priority: P5 - low
Component: REST API
Assignee: koha-bugs at lists.koha-community.org
Reporter: divinity76 at gmail.com
if you send a POST request to /api/v1/patrons with the header
Content-Type: application/x-www-form-urlencoded
which is a default header for curl and libcurl with POST requests, by the way,
then Koha will try to parse it as a JSON, which leads to questions like this
https://stackoverflow.com/questions/68106741/post-koha-patrons-to-koha-lms-using-php-curl/70155185#70155185
and responses like this
```
{
//Here is missing some code.
"errors": [{
"message": "Missing property.",
"path": "/body/address"
},
{
"message": "Missing property.",
"path": "/body/category_id"
},
{
"message": "Missing property.",
"path": "/body/city"
},
{
"message": "Missing property.",
"path": "/body/library_id"
},
{
"message": "Missing property.",
"path": "/body/surname"
}],
"status": 400
}
```
while HTTP 400 is a pretty good response, the correct response for unsupported
Content-Type is actually
>HTTP/1.1 415 Unsupported Media Type
and the error message could be something like
{ "errors": [{
"message": "request body must be application/json"
}],
]
--
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.
More information about the Koha-bugs
mailing list