Bug #6446
closedWe need to either support non-json requests or show an error when a user submits other content types.
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.
Updated by David Davis over 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}
Updated by David Davis over 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.
Updated by David Davis over 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
Updated by David Davis over 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:
Updated by David Davis over 10 years ago
- Related to Bug #6786: Cannot create an organization. added
Updated by The Foreman Bot over 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 (
)
Updated by Anonymous over 10 years ago
- Target version changed from 1.8.0 to 1.7.5
Updated by Dominic Cleal over 10 years ago
- Translation missing: en.field_release set to 10
Updated by David Davis over 10 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset 50ebc024bd5b13b490c41f2b3e5e0c489e7f892b.
Updated by David Davis almost 10 years ago
- Related to Bug #8846: Katello API throws an incorrect error when receiving non-json requests added