【问题标题】:Cannot create a VSTS webhook subscription for punlisherId = tfs and eventId tfvc.checkin via the REST API无法通过 REST API 为 punlisherId = tfs 和 eventId tfvc.checkin 创建 VSTS webhook 订阅
【发布时间】:2018-08-12 22:05:56
【问题描述】:

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

网址: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 Bad Request 作为响应。

响应正文:

{
  "$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 的正确方法。

【问题讨论】:

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


【解决方案1】:

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
}

【讨论】:

    猜你喜欢
    • 2018-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-30
    相关资源
    最近更新 更多