Project

General

Profile

Bug #8846

Katello API throws an incorrect error when receiving non-json requests

Added by Partha Aji about 8 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
Difficulty:
Triaged:
Yes
Bugzilla link:
Fixed in Releases:
Found in Releases:
Red Hat JIRA:

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.


Related issues

Related to Foreman - Bug #6446: We need to either support non-json requests or show an error when a user submits other content types.Closed2014-06-30
Related to Katello - Refactor #8847: Katello's Api::V2::ApiController should inherit Foreman's V2::BaseControllerClosed2015-01-06
Related to Katello - Bug #8862: The V2 API doesn't handle arrays of id/name of has_many relationshipsRejected

Associated revisions

Revision 50c3c9c3 (diff)
Added by David Davis about 8 years ago

Fixes #8846 - Have the V2 api controller extend Api::V2::BaseController

Experiencing a bug where code in Foreman's Api::V2::BaseController is not being
inherited so before filters like check_content_type weren't being executed.
This change has the v2 api controller extend Api::V2::BaseController and as a
result, the Api::ApiController code was moved into a module so it could be
included.

Revision 83c77589
Added by David Davis about 8 years ago

Merge pull request #4899 from daviddavis/temp/20150106144038

Fixes #8846 - Have the V2 api controller extend Api::V2::BaseController

History

#1 Updated by David Davis about 8 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

#2 Updated by David Davis about 8 years ago

  • Related to Refactor #8847: Katello's Api::V2::ApiController should inherit Foreman's V2::BaseController added

#3 Updated by David Davis about 8 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

#4 Updated by The Foreman Bot about 8 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 ()

#5 Updated by David Davis about 8 years ago

  • Related to Bug #8862: The V2 API doesn't handle arrays of id/name of has_many relationships added

#6 Updated by Eric Helms about 8 years ago

  • Legacy Backlogs Release (now unused) set to 14
  • Triaged changed from No to Yes

#7 Updated by David Davis about 8 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#8 Updated by Eric Helms about 8 years ago

  • Legacy Backlogs Release (now unused) changed from 14 to 23

Also available in: Atom PDF