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: [email protected]
Reporter: [email protected]
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.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/