API issues with override_values

I'm attempting to create smart parameter overrides via the API (version
1.13) and I'm having some issues.

Posting to: /api/smart_class_parameters/{paramID}/override_values

JSON being posted:

{
"override_value": {
"match": "hostgroup=somehostgroup",
"value": {"some": "thing"}
}
}

I receive this message back from the API: "error": {"message":"Validation
failed: Value can't be blank"}

The parameter is set to be a hash and I'm passing it a hash, so I can't
figure out why it's reporting the value is blank.

Any ideas?

Thanks.

After some more testing, I found that taking the quotes out of the inside
hash and placing the quotes around the entire hash works:

"value": "{some: thing}"

That works.

The problem is that that's not how it gets reported from the API, if you
query for that information, it quotes in inside hash key and value. I'm
essentially trying to migrate massive amounts of parameter overrides from
one foreman server to another for a server migration and I can't see an
easy way to do that if the json the API spits out on one server cannot be
accepted in that form on the new server.

Does anyone have any experience in importing/exporting parameter overrides
between servers?

Thanks.

ยทยทยท On Monday, October 24, 2016 at 1:24:11 PM UTC-7, Jack Watroba wrote: > > I'm attempting to create smart parameter overrides via the API (version > 1.13) and I'm having some issues. > > Posting to: /api/smart_class_parameters/{paramID}/override_values > > JSON being posted: > > { > "override_value": { > "match": "hostgroup=somehostgroup", > "value": {"some": "thing"} > } > } > > > I receive this message back from the API: "error": {"message":"Validation > failed: Value can't be blank"} > > The parameter is set to be a hash and I'm passing it a hash, so I can't > figure out why it's reporting the value is blank. > > Any ideas? > > Thanks. >

Hi Jack,

Also see: https://bugzilla.redhat.com/show_bug.cgi?id=1192549
and Bug #17087: Updating default_value of a hash/array smart class parameter with a non string value should return an error message - Foreman.

We now run the param through to_json (we're using ruby) then post that.

We are doing a lot of this. Also, as a gotcha, I see you're trying do a
match, note that values you want to match against must be in
override_value_order (hostgroup is by default).

Thanks,
Andrew