[Puppet Users] Foreman API, problem when creating hostgroups

CC foreman users list.

> I am trying to create a hostgroup using the Foreman API
> (foreman-0.4-0.1rc1.noarch):
> Using perl v.5.14.2, REST::Client et. al., ending up with sending:
>
> POST /hostgroups
> {"name":"api-created-
> hostgroup","architecture_id":"","medium_id":"","environment_id":"","operatingsystem_id":"","ptable_id":"","puppetmaster":"puppet.dev.somewhere.com","root_pass":""}
>
> which returns a 422-error
> [that is: 422 Unprocessable Entity (WebDAV) (RFC 4918) - The request
> was well-formed but was unable to be followed due to semantic errors.]
>
>
> Processing HostgroupsController#create (for 10.20.7.81 at 2011-11-20
> 22:14:54) [POST]
> Parameters: {"architecture_id"=>"", "name"=>"api-created-hostgroup",
> "puppetmaster"=>"puppet.dev.somewhere.com", "action"=>"create",
> "root_pass"=>"[FILTERED]", "medium_id"=>"", "ptable_id"=>"",
> "environment_id"=>"", "controller"=>"hostgroups",
> "operatingsystem_id"=>""}
> Failed to save: Name can't be blank or contain trailing white spaces.
> Completed in 47ms (View: 2, DB: 12) | 422 Unprocessable Entity [http://
> puppet.dev.somewhere.com/hostgroups]

it looks like you are missing the hostgroup parameter hash, afair, if
you look at the look, all attributes are values of the key hostgroup.

btw: make sure that you are using the right content-type
(application/json) and pass along the user credentials (as basic auth)
if they are required in your setup.

Ohad

btw: 0.4. has been released and has a lot of enchantments in the api
area, might worth upgrading.

··· 2011/11/20 Poul Sørensen : > > I can easily do "GET /hostgroups" and all the other GET's documented > in the API, so I _think_ that my usage is correct... > but I guess something must be wrong somewhere: > >> Failed to save: Name can't be blank or contain trailing white spaces. > > I even tried with GET/POST (from LWP) > > GET http://apiusername:apiuserpassword@puppet.dev.somewhere.com/hostgroups?format=json > works fine > > echo '{"name":"api-created- > hostgroup","architecture_id":"","medium_id":"","environment_id":"","operatingsystem_id":"","ptable_id":"","puppetmaster":"puppet.dev.somewhere.com","root_pass":""}' > > POST http://apiusername:apiuserpassword@puppet.dev.somewhere.com/hostgroups?format=json > {"errors":[["name","can't be blank or contain trailing white > spaces."]]} > > > Hope you can point out my error! > > Poul > > -- > You received this message because you are subscribed to the Google Groups "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en. > >