You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the [Subscriptions REST APIs](/rest/api/azure/devops/hooks/) , you can programmatically create a subscription that performs an action on an external/consumer service when a specific event occurs in an Azure DevOps project. For example, you can create a subscription to notify your service when a build fails.
18
+
You can use a subscription to perform an action on an external or consumer service when a specific event occurs in an Azure DevOps project. For example, a subscription can notify your service when a build fails. To create a subscription programmatically, you can use the [Subscriptions REST APIs](/rest/api/azure/devops/hooks/).
19
19
20
-
Supported events:
20
+
Azure DevOps provides support for numerous trigger events. Examples include the following events:
21
21
22
22
- Build completed
23
23
- Code pushed (for Git projects)
24
-
- Pull request create or updated (for Git projects)
25
-
- Code checked in (TFVC projects)
26
-
- Work item created, updated, deleted, restored or commented on
24
+
- Pull request created or updated (for Git projects)
25
+
- Code checked in (for Team Foundation Version Control projects)
26
+
- Work item created, updated, deleted, restored, or commented on
27
27
28
-
You can configure filters on your subscriptions to control which events trigger an action. For example, you can filter the build completed event based on the build status. For a complete set of supported events and filter options, see the [Event reference](./events.md).
28
+
To control which events trigger an action, you can configure filters on your subscriptions. For example, you can filter the build completed event based on the build status. For a complete set of supported events and filter options, see [Service hook events](./events.md).
29
29
30
-
For a complete set of supported consumer services and actions, see the [Consumer reference](./consumers.md).
30
+
For a complete set of supported consumer services and actions, see [Service hook consumers](./consumers.md).
|**Data**|- Project ID. Use the [Project REST API](/rest/api/azure/devops/core/projects) to get the project ID.<br>- Event ID and settings. See the [Event reference](./events.md).<br>- Consumer and action IDs and settings. See the [Consumer reference](./consumers.md).|
37
+
|**Data**|- Project ID. Use the [Project REST API](/rest/api/azure/devops/core/projects) to get the project ID.<br>- Event ID and settings. See [Service hook events](./events.md).<br>- Consumer and action IDs and settings. See [Service hook consumers](./consumers.md).|
38
38
39
39
## Create the request
40
40
41
-
Construct the body of the HTTP POST request to create the subscription based on the project ID, event, consumer, and action.
41
+
When you create a subscription, the body of your HTTP POST request specifies the project ID, event, consumer, action, and related settings.
42
42
43
-
See the following example request for creating a subscription that causes a build event to POST to `https://myservice/event` when the build `WebSite.CI` fails.
43
+
You can use the following request to create a subscription for a build completed event. It sends a POST request to `https://myservice/event` when the `WebSite.CI`build fails.
44
44
45
45
**Request**
46
-
```js
46
+
47
+
```json
47
48
{
48
49
"publisherId": "tfs",
49
50
"eventType": "build.complete",
@@ -53,7 +54,7 @@ See the following example request for creating a subscription that causes a buil
@@ -101,21 +103,22 @@ If the subscription request fails, you get an HTTP response code of 400 with a m
101
103
102
104
### What happens when the event occurs?
103
105
104
-
When an event occurs, all enabled subscriptions in the project are evaluated, and the consumer action is performed for all matching subscriptions.
106
+
When an event occurs, all enabled subscriptions in the project are evaluated. Then the consumer action is performed for all matching subscriptions.
105
107
106
108
### Resource versions (advanced)
107
109
108
110
Resource versioning is applicable when an API is in preview. For most scenarios, specifying `1.0` as the resource version is the safest route.
109
111
110
-
The event payload sent to certain consumers, like Webhooks, Azure Service Bus, and Azure Storage, includes a JSON representation of subject resource (for example, a build or work item). The representation of this resource can have different forms or versions.
112
+
The event payload sent to certain consumers includes a JSON representation of a subject resource. For instance, the payload sent to webhooks, Azure Service Bus, and Azure Storage includes information about a build or work item. The representation of this resource can have various forms or versions.
113
+
114
+
You can specify the version of the resource that you want to send to the consumer service via the `resourceVersion` field on the subscription.
111
115
112
-
You can specify the version of the resource that you want to have sent to the consumer service via the `resourceVersion` field on the subscription.
113
-
The resource version is the same as the [API version](../integrate/concepts/rest-api-versioning.md). Not specifying a resource version means "latest released". You should always specify a resource version, which ensures a consistent event payload over time.
116
+
The resource version is the same as the [API version](../integrate/concepts/rest-api-versioning.md). If you don't specify a resource version, the latest version, `latest released`, is used. To help ensure a consistent event payload over time, always specify a resource version.
114
117
115
118
## FAQs
116
119
### Q: Are there services that I can subscribe to manually?
117
120
118
-
A: Yes. For more information about the services that you can subscribe to from the administration page for a project, see the [Overview](./overview.md).
121
+
A: Yes. For more information about the services that you can subscribe to from a project administration page, see [Integrate with service hooks](overview.md).
119
122
120
123
### Q: Are there C# libraries that I can use to create subscriptions?
0 commit comments