override hostgroup paremter using api:
using curl I can get the hosts parameters (here filtered with jq on the .“all_parameters” )
[
{
“priority”: 60,
“created_at”: “2021-06-02 12:15:13 UTC”,
“updated_at”: “2021-06-02 12:15:13 UTC”,
“id”: 27,
“name”: “component_a”,
“parameter_type”: “boolean”,
“value”: true
},
{
“priority”: 60,
“created_at”: “2021-06-02 12:15:13 UTC”,
“updated_at”: “2021-06-02 12:15:13 UTC”,
“id”: 26,
“name”: “component_b”,
“parameter_type”: “boolean”,
“value”: true
},
]
etc
Using the api, I would like to update the value of one of those parameters from ‘true’ to ‘false’.
I tried this:
curl -L https://foreman/api/hosts/20 -u usernam-X PUT -d ‘{“host”: { “parameters”: [ { “parameter_type”: “boolean”, “name”: “component_a”, “value”: false, “priority”: 60} ] } }’ -H ‘Content-Type: application/json’
and this returns a 200 and the host info as json, but it does not override the parameter on the host. If I override it on the web interface, then I see a item appear under the emtpy “parameters” list, with the desired value.
How can I do this in the api? I have been following https://apidocs.theforeman.org/foreman/2.4/apidoc/v2/hosts/update.html but it is a bit unclear