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.
Updated by David Davis almost 10 years ago
- Related to Bug #6446: We need to either support non-json requests or show an error when a user submits other content types. added
Updated by David Davis almost 10 years ago
- Related to Refactor #8847: Katello's Api::V2::ApiController should inherit Foreman's V2::BaseController added
Updated by David Davis almost 10 years ago
- Subject changed from Katello API doesn't throws an incorrect error when receiving non-json requests to Katello API throws an incorrect error when receiving non-json requests
Updated by The Foreman Bot almost 10 years ago
- Status changed from New to Ready For Testing
- Target version set to 63
- Pull request https://github.com/Katello/katello/pull/4899 added
- Pull request deleted (
)
Updated by David Davis almost 10 years ago
- Related to Bug #8862: The V2 API doesn't handle arrays of id/name of has_many relationships added
Updated by Eric Helms almost 10 years ago
- Translation missing: en.field_release set to 14
- Triaged changed from No to Yes
Updated by David Davis almost 10 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset katello|50c3c9c3db8a637e5034d9c1d44d6bc9808eedec.
Updated by Eric Helms almost 10 years ago
- Translation missing: en.field_release changed from 14 to 23