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

Also available in: Atom PDF