Localized $CONTENT_DATA syntax for rules/webhook

Hi,

I’m running Squidex dev-5061 and I’m trying to run a webhook after a page has been updated, published or any of the other events.

The POST from Squidex works fine. It sends the payload from Squidex to my webhook.

The problem I’m having is that I’m not able to retrieve the value of a variable once inside my webhook - I get a null value.

Payload:

{
  "type": "ReviewUpdated",
  "payload": {
    "$type": "EnrichedContentEvent",
    "type": "Updated",
    "id": "775e3977-41ae-47be-8ff5-be74a215eddc",
    "created": "2020-10-21T13:11:25Z",
    "lastModified": "2020-10-21T14:24:37Z",
    "createdBy": "client:dev-my-app:reviewswrite",
    "lastModifiedBy": "subject:5bacceac5935680001f6cba6",
    "data": {
      "myobjectid": {
        "en-US": [
          "84c9aabd4-1232-470c-8d55-775740dc7666"
        ],
        "sv-SE": []
      }
    },
    "dataOld": {
      "myobjectid": {
        "en-US": [
          "84c9aabd4-1232-470c-8d55-775740dc7666"
        ],
        "sv-SE": []
      }
    },
    "status": "Published",
    "partition": -1732732684,
    "schemaId": "8ce4b60e-9211-4f8d-9432-6df2eb80c3c4,review",
    "actor": "subject:5bmcce9c5935680001f6cba6",
    "appId": "1b1836f6-221e-4e1e-8059-3aa3eec5154e,dev-db",
    "timestamp": "2020-10-21T14:24:37Z",
    "name": "ReviewUpdated",
    "version": 11
  },
  "timestamp": "2020-10-21T14:24:37Z"
}

This is the webhook URI:

http://some.domain/webhook?schemaName=$SCHEMA_NAME&contentAction=$CONTENT_ACTION&objIdEnUs=$CONTENT_DATA.myobjectid.en-US&objIdSvSe=$CONTENT_DATA.myobjectid.sv-SE

C# webhook signature:

public async Task OnPostAsync(string schemaName, string contentAction, string objIdEnUs, string objIdSvSe)
        {
...
}

I’ve tried the following syntax:

$CONTENT_DATA.myobjectid.en-US
$CONTENT_DATA.myobjectid.en_US
$CONTENT_DATA.myobjectid.en-us
$CONTENT_DATA.myobjectid.en_us

In the docs there’s nothing about localized $CONTENT_DATA syntax.

I checked https://github.com/Squidex/squidex/blob/master/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleEventFormatterTests.cs
but there’s no localized examples there either.

How do I construct my localized webhook URI?

Thanks!

Your first syntax should work,

BUT if you use it inside a text with no space after the expression the system cannot know where your placeholder ends,

Therefore you have to use ${CONTENT_DATA.myobjectid.en-US}

but this field is an array, so it should be

${CONTENT_DATA.myobjectid.en-US.0}

This worked for me. Thanks Sebastian!

For reference and because I experience some strange UI behavior - most likely due to the Squidex docker image upgrade just before all of these operations (Think of it as starting fresh):

  1. Recreate the rule if you have a very old version of Squidex
  2. Reset “RuleEnqueuer” under Administration > Consumers (“Reset Event Consumer”)
  3. Test your webhook and check the logs under Rules - they’ll give you lots of useful information

Thats weird, but good that you found a workaround. What issues have you experienced exactly?

I wasn’t paying attention but I think that first the UI was from an older Squidex version (because the Secret text field for instance I didn’t have to scroll). Then when I navigated back and forth and was going to configure the URI, Secret and REST (POST) method again I got the newer UI where you have to scroll a bit in order to get to the Secret text field. As soon as I saw this I thought to myself it must be a cache thing or something similar since I updated Squidex version. That’s also why I wasn’t paying attention because I sort of expected some breaking changes here and there.

Another thing that I’ve noted, and that I haven’t been able to reproduce, is that I had to enter the Trigger configuration like two or three times before it actually got saved. I know that at least once I clicked on the Trigger button. And the Schema that I had previously selected + the Condition had been removed from the UI - so I had to select Schema and enter Condition again. I’m still not 100% sure that it will be permanent so I’m planning on doublechecking tomorrow. Right now it looks okay and I did another test and my webhook works.

Let you know if I experience any more Rules issues.

1 Like

Hi Sebastian,

I opened Squidex today to check the Rules that I created yesterday and they are gone:

Edit: I checked my other app in Squidex that I also configured yesterday and the rule that I had created is also not showing up in the UI.

Got any ideas why this might be happening? Let me know if you need help debugging.

Okay, not sure how they could be gone… Have you checked the payload in the network tab? Are you sure that the schemas still exist?

FYI: I checked today just to see if the rules are still there and indeed they are.

PS: I haven’t checked this in several weeks.