Project

General

Profile

Actions

Bug #6446

closed

We need to either support non-json requests or show an error when a user submits other content types.

Added by David Davis about 10 years ago. Updated about 6 years ago.

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

Description

In the API doc, it says you can either use a root node or not. However, this only works with JSON. As in http://projects.theforeman.org/issues/5178, many (or maybe most) API users aren't using JSON.


Related issues 2 (0 open2 closed)

Related to Foreman - Bug #6786: Cannot create an organization.ClosedDavid Davis07/26/2014Actions
Related to Katello - Bug #8846: Katello API throws an incorrect error when receiving non-json requestsClosedDavid Davis01/06/2015Actions
Actions #1

Updated by Joseph Magen about 10 years ago

our API is only JSON format??

Actions #2

Updated by David Davis about 10 years ago

Responded to your email but figured I'd post a copy here too. What do you mean by "our API is only JSON format"? Does that mean that users can't submit form data to the fortello API? Looks like you can to me:

$ curl -X POST http://localhost:3000/api/v2/organizations -d "organization[name]=Test2345" -u admin:changeme
{"ancestry":null,"apply_info_task_id":null,"created_at":"2014-07-17T12:22:48Z","default_info":{"system":[],"distributor":[]},"description":null,"id":7,"ignore_types":[],"katello_default":true,"label":"Test2345","name":"Test2345","owner_auto_attach_all_systems_task_id":null,"title":"Test2345","updated_at":"2014-07-17T12:22:55Z","service_levels":[],"service_level":null} 
Actions #3

Updated by David Davis about 10 years ago

The problem that I've dealt with a few times over the past month with the API users is that they see that requests like this don't work:

$ curl -X POST http://localhost:3000/api/v2/organizations -d "name=Test2345" -u admin:changeme

While requests like this do:

$ curl -X POST http://localhost:3000/api/v2/organizations -d "organization[name]=Test2345" -u admin:changeme

So they get confused and then I get asked questions like "Why does the apidoc say that the params should be un-nested but then I get an error when I send nested params?" and "Why are some api endpoints nested and others aren't?" Maybe the solution is to show an error that we only accept JSON? I don't care either way but I feel like we do need to do something though because I've seen this at least 3 times already.

Actions #4

Updated by David Davis about 10 years ago

  • Subject changed from Consider extending wrap_parameters since a lot of API users aren't using JSON to Since a lot of API users aren't using JSON to send requests, consider extending wrap_parameters or showing an error when they send other content types like application/x-www-form-urlencoded
Actions #5

Updated by David Davis almost 10 years ago

  • Subject changed from Since a lot of API users aren't using JSON to send requests, consider extending wrap_parameters or showing an error when they send other content types like application/x-www-form-urlencoded to We need to either support non-json requests or show an error when a user submits other content types.

Simplifying title.

By the way, here's another example. QA hits an user-unfriendly error when submitting non-json:

https://bugzilla.redhat.com/show_bug.cgi?id=1116043

Actions #6

Updated by David Davis almost 10 years ago

  • Related to Bug #6786: Cannot create an organization. added
Actions #7

Updated by The Foreman Bot almost 10 years ago

  • Status changed from New to Ready For Testing
  • Target version set to 1.8.0
  • Pull request https://github.com/theforeman/foreman/pull/1622 added
  • Pull request deleted ()
Actions #8

Updated by Dominic Cleal almost 10 years ago

  • Assignee set to David Davis
Actions #9

Updated by Anonymous almost 10 years ago

  • Target version changed from 1.8.0 to 1.7.5
Actions #10

Updated by Dominic Cleal almost 10 years ago

  • Translation missing: en.field_release set to 10
Actions #11

Updated by David Davis almost 10 years ago

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

Updated by Bryan Kearney almost 10 years ago

  • Bugzilla link set to 1129769
Actions #13

Updated by David Davis over 9 years ago

  • Related to Bug #8846: Katello API throws an incorrect error when receiving non-json requests added
Actions

Also available in: Atom PDF