I get "The property CallWebhookAfterSubmissionActor is read-only" when trying to update the webhook URL in EpiServer 11

Vote:
 

This is what my test code looks like:

var formIdentity = input as FormIdentity;
var formContainerBlock = formIdentity.GetFormBlock();
var webhookActorModels = formContainerBlock.Content.Property.GetPropertyValue<IEnumerable<WebhookActorModel>>("CallWebhookAfterSubmissionActor").ToList();
if (webhookActorModels == null || webhookActorModels.Count() > 0)
{
    webhookActorModels[0].BaseUrl = "google.com";
}
formContainerBlock.Content.SetPropertyValue("CallWebhookAfterSubmissionActor", webhookActorModels);

And the error I get:

#299682
Apr 06, 2023 18:36
Vote:
 

When is this code being executed? Try calling your block of code when the content is being created.

context.Locate.ContentEvents().CreatingContent += CreatingContent;

https://docs.developers.optimizely.com/content-management-system/v11.0.0-cms/docs/resolving-current-content-context

#299829
Apr 10, 2023 1:50
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.