Unable to set default location via API

Problem:
Using the documentation for the API I can update the value of the location but I can’t update the default parameter for the location.

The following API call works:

curl -H "Content-Type:application/json" -H "Accept:application/json" -u xymon:Applied -X PUT https://foreman.xxxx.xxxx.nl/api/settings/107 -d '{ "setting": { "value": "Default Location" }}'

However when I attempt the same command but tp update the default value:

curl -H "Content-Type:application/json" -H "Accept:application/json" -u xymon:Applied -X PUT https://foreman.xxxx.xxxx.nl/api/settings/107 -d '{ "setting": { "default": "Default Location" }}'

I get this error:
"error": {"message":"No setting value provided."}

I’ve also tried the above API call with both sets of values like this:
curl -H "Content-Type:application/json" -H "Accept:application/json" -u xymon:Applied -X PUT https://foreman.xxxx.xxxx.nl/api/settings/107 -d '{ "setting": { "value": "Default Location", "default": "Default Location" }}'

The above command executes successfully but will only update ‘value’

Expected outcome:
To set the default location
Foreman and Proxy versions:
1.21.3

Hello,
Default values for settings are defined in the source code. specifically for this setting, it is done here. As such, they cannot be changed. Changing the default location is done by changing the value of the default_location setting, not the default value. I have to agree the terms may be a bit confusing here :slight_smile: but default value is the default for the setting, not the default location.

Thanks for you quick response. This has shed some light onto what I’m trying to achieve.

The issue we have is that when new nodes are added into foreman they don’t get a location or organisation set and we have to perform this step manually.

I’l take some time to further look into this but if you have a solution I could try in mind please let me know.

How are the nodes being added? If via puppet, setting the value for the default_organization and default_location settings should already do that.

No it’s done by a VMware tool called VRO. You’ve given me something to think about now at least. I have an idea where to check.
I’ll update here with the fix but it may not be until next week.
Thanks for you input :slight_smile:

1 Like