Project

General

Profile

Bug #6674

Can't create a host via the API because params aren't correctly wrapped

Added by David Davis over 7 years ago. Updated over 7 years ago.

Status:
Duplicate
Priority:
Normal
Assignee:
Category:
API
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

When I try the following curl command, I get "Name can't be blank":

$ curl -k -u admin:changeme -H "Content-Type: application/json" -X POST http://localhost:3000/api/v2/hosts -d '{"name": "TEST"}'

It looks like the name param is getting wrapped in params[:base] instead of params[:host].


Related issues

Related to Foreman - Bug #5178: Users API requires parameters to be wrappedClosed2014-04-14
Is duplicate of Foreman - Bug #6696: API v2 - specify the key in which the parameters would be wrapped rather than passing model nameClosed2014-07-20

History

#1 Updated by Thomas McKay over 7 years ago

  • Bugzilla link set to 1120800

#2 Updated by Thomas McKay over 7 years ago

  • Assignee set to Thomas McKay

#3 Updated by The Foreman Bot over 7 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/1597 added
  • Pull request deleted ()

#4 Updated by Daniel Lobato Garcia over 7 years ago

  • Status changed from Ready For Testing to Rejected

As explained in:

https://github.com/theforeman/foreman/pull/1597#issuecomment-49421858

API POST calls need to receive a wrapped object in a key with the name of the resource you want to create, it's the standard behavior in all POST calls in api/v2

http://theforeman.org/api_v2.html

#5 Updated by David Davis over 7 years ago

  • Status changed from Rejected to Assigned

Please see the following bug:

http://projects.theforeman.org/issues/4181

The API accepts wrapped or unwrapped. The issue here is that when you send unwrapped params, it wraps it in the wrong root node (base instead of host).

#6 Updated by The Foreman Bot over 7 years ago

  • Status changed from Assigned to Ready For Testing

#7 Updated by Joseph Magen over 7 years ago

  • Status changed from Ready For Testing to Duplicate

#8 Updated by Dominic Cleal over 7 years ago

  • Related to Bug #5178: Users API requires parameters to be wrapped added

#9 Updated by Dominic Cleal over 7 years ago

  • Target version deleted (1.8.0)

#10 Updated by Dominic Cleal over 7 years ago

  • Is duplicate of Bug #6696: API v2 - specify the key in which the parameters would be wrapped rather than passing model name added

Also available in: Atom PDF