Similar to Azure Service Bus, we can invoke a Webhook from a plugin (custom Azure-Aware Plugin)
Below is our cloud flow that we have registered as a webhook through the plugin registration tool.
Below is our Webhook registered, note down the ServiceEndpointId.
Below is our code to invoke the Webhook, it uses the same interface, and we IServiceEndPointNotificationService need to provide ServiceEndpointId to it.
We have this registered in the Update message of the Incident.
Let us update a case record and see it in action.
Sample Code –
public class CallWebhookPlugin : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));
IServiceEndpointNotificationService webHookService =
(IServiceEndpointNotificationService)serviceProvider.GetService(typeof(IServiceEndpointNotificationService));
try
{
tracingService.Trace("Posting the execution context to the Webhook.");
// pass the GUID (ServiceEndpointId) of the Webhook
webHookService.Execute(new EntityReference("serviceendpoint",
new Guid("7b88a3c7-d2b5-ee11-a569-0022481c0ba7"))
, context);
tracingService.Trace("Passed Successfully.");
}
catch (Exception e)
{
tracingService.Trace("Exception: {0}", e.ToString());
throw;
}
}
Hope it helps..
One thought on “Invoke webhook from a plugin – Dataverse / Dynamics 365”