Search code examples
c#jsonpower-automate-custom-connector

Setting trigger type for PowerAutomate Webhook in JSON


I have been modifying the swashbuckle filters to add extensions to the endpoints for adding to power automate.

Tried creating a custom connector from the Json created but found that the trigger type was not set. I have checked through the microsoft documentation but there (and elsewhere) it seems the only advice is how to set through their front end.

Is there a way to set this programmatically or will I have to modify this using the front end tool after import?

Thanks.


Solution

  • I ended up by adding through a DocumentFilter as follows:

                foreach (var pathItem in document.Paths)
                {
                    if (pathItem.Key.Contains(TriggerEndpointNaming))
                    {
                        if (!pathItem.Key.Contains("tenantWebHookId"))
                        {                        
                            foreach (var operation in pathItem.Value.Operations)
                            {
                                if (operation.Value.OperationId != null && operation.Value.OperationId.Equals("ManageWebHookAsync"))
                                {
                                    operation.Value.Extensions.Add("x-ms-trigger", new OpenApiString("single"));
                                }
                            }
                        }
                    }
                }