无法通过REST API为punlisherId = tfs和eventId tfvc.checkin创建VSTS webhook订阅

时间:2018-03-05 09:38:19

标签: tfs azure-devops webhooks tfvc azure-devops-rest-api

我正在尝试为publisherId = tfs和eventType = tfvc.checkin创建VSTS webhook订阅。这是示例发布请求:

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

请求正文:

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

我收到了400条错误请求。

回复机构:

{
  "$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
}

有人可以帮助我了解创建此webhook的正确方法。

1 个答案:

答案 0 :(得分:0)

path正在过滤以更改指定路径下的一个或多个文件的签入。它应该看起来像$/TeamProject$/TeamProject/Project$/TeamProject/Project/...$/不受支持。请查看下面的示例:

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
}