Actions
Bug #16403
closedUpdating hostgroups via API with environment_id set fails to find host group
Status:
Duplicate
Priority:
Normal
Assignee:
-
Category:
API
Target version:
-
Description
This worked in 1.10
curl -u user:password -H'Content-Type: application/json' -X PUT -d'{"name": "a123", "title": "a123", "environment_id": 1}' http://localhost:3000/api/v2/hostgroups/5
and it works in Foreman as of 42ba771cc8bfc09257c15c5d388542d4d1b69358 if I leave out the environment_id parameter but not with it.
I've tried different parameters (environment_id, realm_id) but changing these fail with
{
"error": {"message":"Resource hostgroup not found by id '5'"}
}
The log has
08:03:43 rails.1 | 2016-09-01T08:03:43 0a08d560 [app] [I] Started PUT "/api/v2/hostgroups/5" for 127.0.0.1 at 2016-09-01 08:03:43 +0200
08:03:43 rails.1 | 2016-09-01T08:03:43 0a08d560 [app] [I] Processing by Api::V2::HostgroupsController#update as JSON
08:03:43 rails.1 | 2016-09-01T08:03:43 0a08d560 [app] [I] Parameters: {"name"=>"a123", "title"=>"a123", "environment_id"=>1, "apiv"=>"v2", "id"=>"5", "hostgroup"=>{"name"=>"a123", "environment_id"=>1, "title"=>"a123"}}
08:03:43 rails.1 | 2016-09-01T08:03:43 0a08d560 [app] [D] Setting current user thread-local variable to foreman_admin
08:03:43 rails.1 | 2016-09-01T08:03:43 0a08d560 [app] [D] Setting current user thread-local variable to nil
08:03:43 rails.1 | 2016-09-01T08:03:43 0a08d560 [app] [D] Setting current user thread-local variable to foreman_admin
08:03:43 rails.1 | 2016-09-01T08:03:43 0a08d560 [app] [D] Setting current user thread-local variable to nil
08:03:43 rails.1 | 2016-09-01T08:03:43 0a08d560 [app] [D] Setting current user thread-local variable to user
08:03:43 rails.1 | 2016-09-01T08:03:43 0a08d560 [app] [I] Authorized user user(user)
08:03:43 rails.1 | 2016-09-01T08:03:43 0a08d560 [app] [D] Setting current user thread-local variable to user
08:03:44 rails.1 | 2016-09-01T08:03:44 0a08d560 [app] [I] Couldn't find Hostgroup with 'id'=5 [WHERE ("environments"."id" = 1 OR "environments"."name" = '1')] (ActiveRecord::RecordNotFound)
08:03:44 rails.1 | 2016-09-01T08:03:44 0a08d560 [app] [I] Rendered api/v2/errors/not_found.json.rabl within api/v2/layouts/error_layout (0.6ms)
08:03:44 rails.1 | 2016-09-01T08:03:44 0a08d560 [app] [I] Completed 404 Not Found in 69ms (Views: 3.7ms | ActiveRecord: 47.3ms)
Updated by Dominic Cleal about 8 years ago
- Related to Bug #13775: Not able to change an HG for a host using API call added
Updated by Dominic Cleal about 8 years ago
- Subject changed from Updating hostgroups via API fails to Updating hostgroups via API with environment_id set fails to find host group
- Category set to API
The log shows that it's interpreting the environment ID as a search clause, it's finding a host group where the environment ID is 1.
I think this is probably the same as #13775, where the attribute is interpreted as a nested API call. If you wrap the whole data structure in {"hostgroup":{...}} then it should be ignored.
Updated by Guido Günther about 8 years ago
- Status changed from New to Closed
Yes, this is indeed a duplicate of #13775.
Updated by Dominic Cleal about 8 years ago
- Status changed from Closed to Duplicate
Actions