我使用 Trello 的 API 添加了 Webhooks(Node JS 包)。 如何获取当前的 Webhook 或如何获取现有的 Webhook ID?
无法通过 API 找到方法: https://developers.trello.com/advanced-reference/webhook
这里它说:
删除 webhook 的方法有3种。
- 在 webhooks 上使用 DELETE 路由 删除 https://api.trello.com/1/webhooks/[WEBHOOK_ID]?key=[APPLICATION_KEY]&token=[USER_TOKEN]
- 如果来自 Trello 的 Webhook 请求在 POST 到回调URL 时收到 HTTP 410 Gone 响应,则 Webhook 将被删除。
- 如果webhook绑定的token被撤销或过期,则webhook将被删除
第一种方法需要 ID,第二种方法要求我每次想要删除 Webhook 时都关闭服务器,第三种方法也不是更好。知道如何获取 ID 吗?
以下是获取应用程序已创建的所有 Webhook 的 API 请求:
GET https://api.trello.com/1/members/me/tokens?webhooks=true&key=[APPLICATION_KEY]&token=[USER_TOKEN]
下面列出了 Trello API 文档 /1/members/[id]/tokens 的相关部分:
GET /1/members/[idMember 或用户名]/tokenslink 所需权限:读取、拥有、帐户
论点另请注意,
filter
(可选)默认:
- 有效值:以下之一:
all
all
、none
webhooks
(可选)默认:
- 有效值:以下之一:
false
true
、false
me 用作 idMember 或用户名
注意:如果您指定请参阅 这是我得到的 JSON 响应示例:me 作为用户名,此调用将做出响应,就好像您提供了与所提供的令牌关联的用户名
{
"id": "568d40cc3aa021f1b3602ea0",
"identifier": "Server Token",
"idMember": "562d50bc3aa020f1b3602ec0",
"dateCreated": "2016-05-30T22:01:15.721Z",
"dateExpires": null,
"permissions": [
{
"idModel": "562d50bc3aa071f1b3602ec6",
"modelType": "Member",
"read": true,
"write": true
},
{
"idModel": "*",
"modelType": "Board",
"read": true,
"write": true
},
{
"idModel": "*",
"modelType": "Organization",
"read": true,
"write": true
}
],
"webhooks": [
{
"id": "5675a0a8159fbeef4b796da3",
"description": "Feature Requests Board",
"idModel": "55a1176a0b620663da985753",
"callbackURL": "http://example.com/trello/webhook-callback?type=features",
"active": true
},
{
"id": "5673a0ac6ab60af7ec3a706b",
"description": "Bugs Board",
"idModel": "541ebcf34c03910922ff0fc3",
"callbackURL": "http://example.com/trello/webhook-callback?type=bugs",
"active": true
}
}
https://api.trello.com/1/tokens/{{userToken}}/webhooks?key={{appKey}}
它工作正常。它返回所有 webhook。数据如下
[
{
"id": "*****427fb4***dsucd475*****",
"description": "my test webhook",
"idModel": "*****8df4sdy9u5gd6886f20c*****",
"callbackURL": "https://******sum.ngrok-free.app/trello-webhook",
"active": true,
"consecutiveFailures": 0,
"firstConsecutiveFailDate": null
}
]