Can't create rule with REST API

CMK version: 2.1.0p4
Error message:

Traceback (most recent call last):
  File "./cmk_rest_api.py", line 90, in <module>
    raise RuntimeError(pprint.pformat(send.json()))
RuntimeError: {'detail': "Value ['cert', {'cert_days': [29, 14]}] is not allowed here.",
 'status': 400,
 'title': "Problem in (sub-)field 'mode_sel'"}

When I try to make an HTTP service rule with the REST API, this error occurs in the “value_raw” section. The string I use in this section is copy-pasted from another rule I read from the API, so it shouldn’t be wrong. I think it’s a bug in the API.

Found the problem: the given square brackets [] need to be round brackets (). But I still don’t know why the API output is with square brackets

2 Likes

Thanks @paulr282 for taking the time to post after resolving your own issue. I just ran into the same thing today and your post allowed me to solve the problem quickly.

Personally I think this should be considered a bug in the API. In my opinion, the input and output formats should be the same. With that said, maybe there are reasons that they need to be different in this specific case.

Note also that the Export this rule for API link in the web UI does provide the correct format that uses round brackets.

I also solved it coincidentally by the Export in the UI.

1 Like