Unable to update consents for a profile in Apache Unomi

74 Views Asked by At

I am trying to add consents for a profile using curl request as provided in Apache Unomi documentation:

curl -X POST http://localhost:8181/cxs/context.json?sessionId=1234 \
-H "Content-Type: application/json" \
-d @- <<'EOF'
{
    "source":{
        "itemId":"homepage",
        "itemType":"page",
        "scope":"example"
    },
    "events": [
        {
            "scope":"unomi-tracker-test",
            "eventType":"modifyConsent",
            "source":{
                "itemType":"page",
                "scope":"example",
                "itemId":"anItemId"
            },
            "target":{
                "itemType":"profile",
                "scope":"unomi-tracker-test",
                "itemId":"d501a4be-8568-484d-8550-a01a6a13aca2"},
            "properties":{
                "consent":{
                    "typeIdentifier":"newsletter",
                    "scope":"unomi-tracker-test",
                    "status":"GRANTED",
                    "statusDate":"2018-05-22T09:27:09.473Z",
                    "revokeDate":"2020-05-21T09:27:09.473Z"
                }
            }
        }
    ]
}
EOF

On hitting this POST request, the consents are not updated in profile.

Here, I have replaced itemType for target with "profile" and itemId with my profileId.

Is there anything else I am missing?

2

There are 2 best solutions below

1
On

I understand Unomi doesn't do anything until you add the rule and scheme yourself.

0
On

It seems you need to have your json updated with correct data, refer source section and scope in below json (works perfectly),

    {
    "source": {
        "itemId": "unomi-tracker-test-page",
        "itemType": "page",
        "scope": "unomi-tracker-test"
    },
    "events": [
        {
            "scope": "unomi-tracker-test",
            "eventType": "modifyConsent1",
            "source": {
                "itemType": "site",
                "scope": "unomi-tracker-test",
                "itemId": "unomi-tracker-test"
            },
            "target": {
                "itemType": "page",
                "scope": "unomi-tracker-test",
                "itemId": "unomi-tracker-test-page"
            },
            "properties": {
                "consent": {
                    "typeIdentifier": "newsletter",
                    "scope": "unomi-tracker-test",
                    "status": "GRANTED",
                    "statusDate": "2018-05-22T09:27:09.473Z",
                    "revokeDate": "2020-05-21T09:27:09.473Z"
                }
            }
        }
    ]
}