Project

General

Profile

Actions

Bug #8846

closed

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

Added by Partha Aji almost 10 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
Difficulty:
Triaged:
Yes
Fixed in Releases:
Found in Releases:

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 3 (0 open3 closed)

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

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
Actions #2

Updated by David Davis almost 10 years ago

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

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
Actions #4

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 ()
Actions #5

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
Actions #6

Updated by Eric Helms almost 10 years ago

  • Translation missing: en.field_release set to 14
  • Triaged changed from No to Yes
Actions #7

Updated by David Davis almost 10 years ago

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

Updated by Eric Helms almost 10 years ago

  • Translation missing: en.field_release changed from 14 to 23
Actions

Also available in: Atom PDF