V2 API: Unable to create override_values for smart class parameter

Hi All,

Im having some problems using the v2 API on foreman 1.4.2. I am trying to
add an override matcher to a smart class parameter. Everything works using
the foreman GUI but I get an error when I make this API call:

POST /api/smart_class_parameters/437/override_values (437 is the id of
the parameter)
POST DATA: {'override_value': {'match': 'environment=development',
'value': 'mynewval'}}

I have also tried sending this data as per the documentation:

{
"override_value": {
"match": "xyz=10",
"value": "string"
}}

But the same error occurs:

"error": {"message":"undefined method `match' for nil:NilClass"}
Any ideas? Is this a bug? I'm updating other objects using the API without any problems.

Thanks
Jeff

Ah, that fixed it. Thanks

··· On Wednesday, 2 April 2014 11:57:59 UTC+1, Jeff wrote: > > Hi All, > > Im having some problems using the v2 API on foreman 1.4.2. I am trying to > add an override matcher to a smart class parameter. Everything works using > the foreman GUI but I get an error when I make this API call: > > POST /api/smart_class_parameters/437/override_values (437 is the id of > the parameter) > POST DATA: {'override_value': {'match': 'environment=development', > 'value': 'mynewval'}} > > I have also tried sending this data as per the documentation: > > { > "override_value": { > "match": "xyz=10", > "value": "string" > }} > > But the same error occurs: > > > "error": {"message":"undefined method `match' for nil:NilClass"} > Any ideas? Is this a bug? I'm updating other objects using the API without any problems. > > Thanks > Jeff > > >

I think you get this error if the parameters aren't found in the
request, so my guess is that you're missing the "Content-Type:
application/json" header.

··· On 02/04/14 11:57, Jeff wrote: > Hi All, > > Im having some problems using the v2 API on foreman 1.4.2. I am trying > to add an override matcher to a smart class parameter. Everything works > using the foreman GUI but I get an error when I make this API call: > > POST /api/smart_class_parameters/437/override_values (437 is the id of > the parameter) > POST DATA: {'override_value': {'match': 'environment=development', > 'value': 'mynewval'}} > > I have also tried sending this data as per the documentation: > > { > "override_value": { > "match": "xyz=10", > "value": "string" > } > } > > But the same error occurs: > > > "error": {"message":"undefined method `match' for nil:NilClass"} > > Any ideas? Is this a bug? I'm updating other objects using the API without any problems.


Dominic Cleal
Red Hat Engineering