Hello All -
I followed the guide here, and got triggers working via webhooks - apart from the webhook delete calls. What exact criteria need to be met for delete to work? I have defined the delete call in the swagger doc, and have made sure to return a Location header in the 201 create request - and that request matches the pattern of the delete call I've defined. However, the delete call is not being made correctly. Can anyone help?
Cheers,
Matt
Hi @Syndicate_Admin ,
The only thing I know is that my endpoint did not provide a location header in the response. This was an API of a software provider and they will not add the header. So, that means Power Automate will not be able to communicate via a webhook with this API, unfortunately. And that meant the end of it for me.
Thanks @murshed ! I will need to submit a feature request then, that's a pity.
@JOAS_Niels Yes.
https://docs.microsoft.com/en-us/connectors/custom-connectors/create-webhook-trigger
Important
In order for Logic Apps or Power Automate to delete a webhook, the API must include a Location HTTP header in the 201 response at the time the webhook is created. The Location header should contain the path to the webhook that is used with the HTTP DELETE. For example, the Location included with GitHub's response follows this format: https://api.github.com/repos/<user name>/<repo name>/hooks/<hook ID>.
Just to be sure. Does this mean that the owner of the API of the webhook should add a location header to the API? I'm not the owner, so I will need to ask for it then.
Hello,
I found my issue. I upgraded my project from .NET framework to .NET Core. However the create webhook method was still returning a HttpResponseMessage which is no longer supported as a response type in a Controller in the .NET Core WebApi. So my whole response (including my location header) was begin returned in the body. I changed this to IActionResult and now it is working correctly.
So indeed it works by having the Location header in the create webhook response and the path of the location header as an internal delete action.
All the best,
Matthijs
Hello Dmitry,
Yes I tried a few delete webhooks via the test section. All my deletes have a 415 error code in the test section of a custom connector. Even my delete document, while the flow action for this works perfectly (and is also already certified). as you can see in the provided delete action in the swagger I don't have any body parameters. I do have consumes and produces "application/json" on top level of my swagger file.
My create webhook response does give a Location header as far as I can see:
{
"version": "1.1",
"content": null,
"statusCode": 200,
"reasonPhrase": "OK",
"headers": [
{
"key": "Location",
"value": [
"https://<myhost>.azurewebsites.net/api/web-hook/delete/45"
]
}
],
"trailingHeaders": [],
"requestMessage": null,
"isSuccessStatusCode": true
}
All the best,
Matthijs
Hi MatthijsB,
I think I found logs related to your connector and it looks like there is no Location header in a create webhook response.
One such subscription request that was sent from the connector (2020-12-09): POST https://<yourhost>.azurewebsites.net/api/web-hook/create/DocumentPropertiesUpdated. The response was successful, but there was no Location header based on logs.
I can also see few DELETE request, perhaps, it was a testing with direct action calls (webhookId=20). All of them failed with 415 status code, it looks like there is some payload passed along with those requests and Content-Type=text/plain.
Best regards,
Dmitry
Hello Dmity,
My location header value is exactly the same as my swagger delete operation URL, so this is not the problem.
location header: https://myhost.azurewebsites.net/api/web-hook/delete/42
swagger host: myhost.azurewebsites.net
swagger basePath: /
swagger scheme: https
swagger path: /api/web-hook/delete/{id}
All the best,
Matthijs
Hi folks,
It looks like there is one missing requirements for webhook unsubscribe operations which must be authorized as other operation in a connector. Besides having DELETE operation in the connector swagger, Location header value must start with the registered backend service Url. So, if you have delete operation template in swagger:
"/api/web-hook/delete/{id}" {"delete": {...}}
and your connector's host is 'https://myhost.com' and your Base Url is '/restapi/v2', Location header must have the following value: 'https://myhost.com/restapi/v2/api/web-hook/delete/<some id>'
Best regards,
Dmitry
Hello,
This is still not working for me. The webhook is being subscribed without a problem, but never unsubscribes itself.
I have a delete action on my REST controller and I tested it directly with the URL I add to the header when subscribing and the Rest call works. I add the following to the subscribe action: responseMessage.Headers.Add("Location", $"{host}/api/web-hook/delete/{id}");
I also tried to add an internal action to my swagger file but still nothing (I also tried without the id as parameter but hardcoded to an old subsciption, still nothing):
"/api/web-hook/delete/{id}": {
"delete": {
"responses": {
"200": {
"description": "OK"
}
},
"summary": "Delete WebHook",
"description": "Delete the WebHook",
"operationId": "DeleteWebHook",
"x-ms-visibility": "internal",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string",
"x-ms-visibility": "important",
"x-ms-url-encoding": "single",
"x-ms-summary": "ID",
"description": "Specify the ID of the WebHook"
}
]
}
}
EDIT:
I changed it so that the ID is also hardcoded an not needed in the delete call (removed it from the response header and swagger) and I made the delete call on the REST API open for everyone and still nothing. Added logging on the first line of the method and the method doesn't even get called.
Thanks in advanced!
Matthijs