Hostgroups API (v2) change in foreman 1.8?

> Hi All,
> We are in the process of moving from foreman 1.6.1 to 1.8.1 and have
> noticed a difference in behaviour with the hostgroup V2 API. Previously,
> following the documentation, we create hostgroups in a given environment
> using the following API call:
> POST /api/hostgroups
> {'environment_id': 1, 'name': 'myhgname'}
> In foreman 1.6.1 this worked as expected, a hostgroup would be created in
> the relevant environment. In foreman 1.8.1 the same API call returns the
> following error:
> {
> "error": {"message":"environment_id is not allowed as nested parameter
> for hostgroups. Allowed parameters are puppetclass_id, location_id,
> organization_id"}
> }
> The documentation has not changed and still states that environment_id is
> an optional parameter that allows the hostgroup to be created in a specific
> environment.
> Can anyone help? Is this a bug or intended behaviour?

Seems like a bug. I could reproduce it on 1.8.2 even, but not on the
latest 1.9 RC, so it's fixed. I haven't tried making a PUT request
changing the environment after creating the hostgroup with just the
name, could be a workaround.

··· On 07/17, Jeff wrote:


You received this message because you are subscribed to the Google Groups “Foreman users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

Daniel Lobato Garcia