apirestazure-devopswebhooksazure-service-hooks

Is there any way to create a subscription on any/multiple event types using Azure DevOps Rest API?


I'm quite new to Azure DevOps Rest API but until now I've managed to create service hooks subscriptions using it. The problem is that my initial goal was to create a single subscription that responds to multiple or any event type. Here is what I have until now, which works fine:

{
  "publisherId": "tfs",
  "eventType": "git.push",
  "consumerId": "webHooks",
  "consumerActionId": "httpRequest",
  "consumerInputs": {
    "url": "my_url"
  }
}

This is just a simple POST request at https://dev.azure.com/{my_organization}/_apis/hooks/subscriptions. I was wondering if there is any way to create webHooks subscriptions that listen to any eventType from any publisherId (by supplying a null value to the publisherId/eventType for instance). Or is there any other way I can create a webHook for multiple events? I've tried passing an array of events to the eventType but this fails as eventType must be a String as the documentation says: https://learn.microsoft.com/en-us/rest/api/azure/devops/hooks/subscriptions/create?view=azure-devops-rest-5.0


Solution

  • It seems that you want to create one webhook and listen to all eventType, we cannot do this. You could refer to this doc to check all support event types.

    Since the field eventType type is String instead of Array, we could only create one eventType for one request, it is same as create webhook in the UI, If you want to receive all the eventType message, we recommend that you create multiple webhooks.