[REST API] Activate changes not working: "Currently there are no changes to activate."

CMK version: 2.1.0p6
OS version: Ubuntu 20.04

Error message: {"title": "The operation has failed.", "status": 422, "detail": "Currently there are no changes to activate."}

I have a automation user called vhost-ctrl. With that user (Authorization: Bearer USER PASS) I write new rules.

After wriring rules, I want to activate the changes by posting {"redirect":false,"sites":[]} to /domain-types/activation_run/actions/activate-changes/invoke.

But the API responses with 422 - No changes to activate. Even without sending sites. Omitting sites should do changes in any site, per documentation. That is what I want to achieve. Specify the right sites does not work either.

But opening the GUI as cmkadmin clearly states the opposite:

What have I forgotten?

Headers for posting to the endpoint:

            "Authorization: Bearer USER PASS,
            'Content-Type: application/json'

Thanks in advance :slight_smile:

Does no one use activate changes via REST?

Still an issue with p11:

Exception 'Exception' with message 'Activation failed! {"title": "The operation has failed.", "status": 422, "detail": "Currently there are no changes to activate."}' but there are!

No change with p12.

/domain-types/activation_run/actions/activate-changes/invoke still returns {"title": "The operation has failed.", "status": 422, "detail": "Currently there are no changes to activate."} but thats not true:

EDIT: No matter, if I post
{"redirect":false,"force_foreign_changes":false} or
{"redirect":false,"force_foreign_changes":true} or

Issue still persist with 2.1.0p13 :frowning:

Hi Robin, can you provide the exact API call you are performing?
Maybe a minimum working example of your code?

Hi Robin :slight_smile: Thanks for checking this one.

The request is posted in the initial post - but here again:

Endpoint: http://cmkserver/qlb/check_mk/api/1.0/domain-types/activation_run/actions/activate-changes/invoke
Method: POST
Headers: "Authorization: Bearer User:PW and Content-Type: application/json
Body: {"redirect":false,"sites":[],"force_foreign_changes":true} (tested with empty sites and specified site)

Code is a simple PHP curl one, nothing special.

Hi Robin, your call seems to be fine, it works in my environment.
This might be a permission issue. Is the user allowed to activate (foreign) changes?

Hi :slight_smile:

The user, who is calling the API:

It is an admin user, so there should no permission issue.

Anything else, I could test?

@robin.gierse Something new? :slight_smile:

To be more clear - there are no foreign changes to activate, it just shows the webUI as cmkadmin. The mentioned vhost_ctrl user is the author of all changes and later CMK should apply its own changes.

So theoretically, foreign changes do not even come to play.

I have not seen this issue with other users or customers, so my gut still tells me, it is a local problem at your end. If it is still not resolved, I recommend opening a support ticket, as that enables us to take a look together. From the distance I cannot reproduce your problem in a fresh and current site. Can you? :thinking:

I had this issue and could fix it by adding a time.sleep(5) in my python hook:

def activate():
    request = {
        'redirect': False,
        'sites': [],
        'force_foreign_changes': True
    session = create_session()
    resp = session.post("{}/domain-types/activation_run/actions/activate-changes/invoke".format(APIURL),
            headers={"Content-Type": 'application/json'}, json=request, allow_redirects=True)

    if resp.status_code in {200, 204}:
        raise RuntimeError(pprint.pformat(resp.json()))

Like Robin, I have also used the API to successfully activate changes.

What variant of CheckMK are you using? Raw, Enterprise Free, full paid Enterprise, etc
Are you working with a distributed monitoring environment?