Bug #8846
closedKatello API throws an incorrect error when receiving non-json requests
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1179448
When I run the following against our Katello API:
❯ curl -k -u admin:changeme localhost:3000/katello/api/v2/organizations/3/systems/a0ce0ce7-7935-4298-9557-9e6abbe67224 -XPUT -d'{"content_view_id": "19", "type": "system"}'
{"displayMessage":"Missing values for system.","errors":["param is missing or the value is empty: system"]}
However I'd expect a 415 since curl by default uses x-www-form-urlencoded or whatever for PUT requests. Here's a foreman example:
❯ curl -k -u admin:changeme -XPUT localhost:9292/api/v2/operatingsystems/1 -d'{"name": "test"}'
{
"error": {"message":"'Content-Type: application/x-www-form-urlencoded' is unsupported in API v2 for POST and PUT requests. Please use 'Content-Type: application/json'."}
}
I think this is because our Katello API controllers aren't extending foreman's Api::V2::BaseController.