How to add rules to OneLogin App via API?

23 Views Asked by At

I'm trying to add AWS Accounts to OneLogin automatically. This by itself does work flawlessly using the API. Now I'd also like to add rules to the just-created app. This doesn't work at all. The endpoint only gives a 404 response. I can add rules for this app as I like within the UI.

List Rules API doc states that the URL scheme is https://subdomain/api/2/apps/:app_id/rules. Assuming my created app has the ID 2455, the URL should be https://subdomain/api/2/apps/2455/rules.

$ curl 'https://mycompany.onelogin.com/api/2/apps/2455/rules' -X GET -H "Authorization: bearer myTokenHere"
{"name":"NotFoundError","message":"Resource not found","statusCode":404}

Bluntly copying the sample from the create-rule API doc gives the same result.

$ curl 'https://mycompany.onelogin.com/api/2/apps/2455/rules' \
-X POST \
-H "Authorization: bearer myTokenHere" \
-H "Content-Type: application/json" \
-d '{
    "name": "My Second Rule",
    "match": "all",
    "enabled": true,
    "position": null,
    "conditions": [
        {
            "source": "last_login",
            "operator": ">",
            "value": "90"
        }
    ],
    "actions": [
        {
            "action": "set_status",
            "value": "2"
        }
    ]
}'
{"name":"NotFoundError","message":"Resource not found","statusCode":404}

The connector ID is 30319 - Amazon Web Services (AWS) - SAML.

What am I doing wrong here?

0

There are 0 best solutions below