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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无法通过REST API为punlisherId = tfs和eventId tfvc.checkin创建VSTS webhook订阅相关的知识,希望对你有一定的参考价值。

我正在尝试为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的正确方法。

答案

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
}

以上是关于无法通过REST API为punlisherId = tfs和eventId tfvc.checkin创建VSTS webhook订阅的主要内容,如果未能解决你的问题,请参考以下文章

woocommerce通过rest api验证用户名和密码

无法让spring boot hibernate rest api返回一对多关系

为啥我无法通过官方 Binance REST API 使用 c# 进行 Binance 订单?

通过 Rest Api 订阅 Microsoft Graph Api Webhook 不再有效

Wordpress 5.4。 REST API通过子弹无法工作

Paypal Rest API - 提交帐单地址