0
votes

I am trying to create a VSTS webhook subscription for publisherId= tfs and eventType= tfvc.checkin. Here's the sample Post request :

Url : https://testvstsaccount.visualstudio.com/_apis/hooks/subscriptions?api-version=1.0

Request Body :

{
  "publisherId": "tfs",
  "eventType": "tfvc.checkin",
  "resourceVersion": "1.0-preview.1",
  "consumerId": "webHooks",
  "consumerActionId": "httpRequest",
  "publisherInputs": {
    "path": "$/"
  },
  "consumerInputs": {
    "url": "https://myservice/myhookeventreceiver"
  }
}

I am getting 400 Bad Request in response.

Response body :

{
  "$id": "1",
  "innerException": null,
  "message": "Subscription input 'path' is not supported at scope 'collection'.",
  "typeName": "Microsoft.VisualStudio.Services.ServiceHooks.WebApi.SubscriptionInputException, Microsoft.VisualStudio.Services.ServiceHooks.WebApi, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
  "typeKey": "SubscriptionInputException",
  "errorCode": 0,
  "eventId": 4501
}

Can someone please help me understand the correct way to create this webhook.

1
I have also tried the following request url : testvstsaccount.visualstudio.com/DefaultCollection/_apis/hooks/… . I get the same error.cb177
Shouldn't it contain 'DefaultCollection' in the URL? Like this: testvstsaccount.visualstudio.com/DefaultCollection/_apis/hooks/…Yan Sklyarenko
@YanSklyarenko : You are right. I tried that as well. As mentioned in my previous comment, i tried that as well.cb177
Looks like it complains about 'path' property, but I can't find the 'path' property in the sample JSON request here: visualstudio.com/en-us/docs/integrate/api/hooks/….Yan Sklyarenko
The sample listed at this link offers publisherInputs for eventType: build.complete. Infact, I get the following error when I used the sample for eventType : tfvc.checkin. The error message says : "message": "Unknown subscription input \"branch\" for publisher \"Team Foundation Server\" and event type \"Code checked in\".". I got the required inputDescriptors for eventType:tfvc.checkin by using api : "testvstsaccount.visualstudio.com/_apis/hooks/publishers/…".cb177

1 Answers

0
votes

The path is filtering to checkins that change one or more files under the specified path. It should look like $/TeamProject, or $/TeamProject/Project, or $/TeamProject/Project/.... $/ is not supported. Check my example below:

POST https://xxx.visualstudio.com/DefaultCollection/_apis/hooks/subscriptions?api-version=1.0

Content-Type: application/json

{
  "consumerActionId": "httpRequest",
  "consumerId": "webHooks",
  "consumerInputs": { "url": "https://xxx.visualstudio.com" },
  "eventType": "tfvc.checkin",
  "publisherId": "tfs",
  "publisherInputs": {
    "path": "$/TestCase/TestCaseProject",
    "projectId": "1decf66b-1974-43e3-xxxx-ba9a3fd2xxxx"
  },
  "resourceVersion": "1.0",
  "scope": 1
}