【发布时间】: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 的正确方法。
【问题讨论】:
-
我也尝试过以下请求网址:testvstsaccount.visualstudio.com/DefaultCollection/_apis/hooks/…。我得到同样的错误。
-
URL中不应该包含'DefaultCollection'吗?像这样:testvstsaccount.visualstudio.com/DefaultCollection/_apis/hooks/…
-
@YanSklyarenko:你是对的。我也试过了。正如我之前的评论中提到的,我也尝试过。
-
看起来它抱怨“路径”属性,但我在此处的示例 JSON 请求中找不到“路径”属性:visualstudio.com/en-us/docs/integrate/api/hooks/…。
-
此链接中列出的示例为 eventType:build.complete 提供了 publisherInputs。事实上,当我使用 eventType 的示例时,我收到以下错误:tfvc.checkin。错误消息显示:“消息”:“发布者“Team Foundation Server”的未知订阅输入“分支”和事件类型“签入代码”。”。我通过使用 api 获得了 eventType:tfvc.checkin 所需的 inputDescriptors:“testvstsaccount.visualstudio.com/_apis/hooks/publishers/…”。
标签: tfs azure-devops webhooks tfvc azure-devops-rest-api