Microsoft Flow 自定义连接器 webhook 触发器定义和实现:创建流后找不到 404
Microsoft Flow Custom Connector webhook trigger definition and implementation : 404 not found after flow creation
我正在尝试在 Microsoft Flow 中为我的 API 创建一个自定义连接器,以便用户可以基于 webhook 实现触发流。
身份验证部分似乎工作正常(我能够创建连接)。使用我的自定义触发器创建流程后,它永远不会被触发。在我这边检查数据时,似乎 Flow 无法正确注册订阅。
如果我导航到流程的管理页面,我会收到以下错误消息。
当我单击修复触发器时,我得到以下详细信息 ,其中 Id 参数与我们尝试订阅的资源的 ID 相匹配。
这是触发器定义:
{
"/AlertRules/{id}/webhooks": {
"x-ms-notification-content": {
"schema": {
"type": "object",
"properties": {
"Title": {
"type": "string",
"description": "Title"
},
"Text": {
"type": "string",
"description": "Text"
},
"Data": {
"type": "array",
"items": {
"$ref": "#/definitions/DataApi.Models.AlertEvent"
},
"description": "Data"
}
}
},
"description": ""
},
"post": {
"responses": {
"201": {
"description": "Created",
"schema": {
"type": "string"
}
}
},
"x-ms-trigger": "single",
"operationId": "NewAlertEvent",
"summary": "When a new Alert Event is created or updated",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string",
"x-ms-visibility": "important",
"x-ms-dynamic-values": {
"operationId": "AlertRules.AlertRule.ListAlertRule",
"value-path": "Id",
"value-collection": "value",
"value-title": "Description"
}
},
{
"name": "body",
"in": "body",
"required": false,
"schema": {
"type": "string",
"x-ms-visibility": "internal",
"title": "",
"x-ms-notification-url": true
},
"x-ms-visibility": "internal"
}
]
}
}
我的删除操作说明
{
"/AlertRuleSubscriptions({Id})": {
"delete": {
"tags": [
"AlertRuleSubscriptions.AlertRuleSubscription"
],
"summary": "Delete entity from AlertRuleSubscriptions",
"operationId": "AlertRuleSubscriptions.AlertRuleSubscription.DeleteAlertRuleSubscription",
"parameters": [
{
"in": "path",
"name": "Id",
"description": "key: Id",
"required": true,
"type": "string",
"format": "uuid",
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
"x-ms-docs-key-type": "AlertRuleSubscription"
},
{
"in": "header",
"name": "If-Match",
"description": "ETag",
"type": "string"
}
],
"responses": {
"204": {
"description": "Success"
},
"default": {
"$ref": "#/responses/error"
}
},
"x-ms-docs-operation-type": "operation"
}
}
}
并且我的 post 操作确实使用与上述删除操作的格式匹配的位置 header 进行回复。
我的问题是:
- 我的触发器声明中缺少什么?
- 如何获取有关订阅创建和 Microsoft Flow 生成的错误的更多详细信息?
在与 Microsoft 进行一些内部讨论后,我们发现了两个主要问题。
首先,我更新了 POST 请求的正文参数以创建对此的订阅。
{
"name": "body",
"in": "body",
"required": false,
"schema": {
"type": "object",
"properties": {
"callbackUrl": {
"type": "string",
"required": true,
"description": "callbackUrl",
"x-ms-notification-url": true,
"x-ms-visibility": "internal"
}
}
}
}
这是因为连接器定义不支持在不使用 JSON 格式的情况下在正文中发送回调 URL,并且因为 Flow 已实现 using the Open API callback specification.
其次,我更新了 API 以支持上述规范。
我正在尝试在 Microsoft Flow 中为我的 API 创建一个自定义连接器,以便用户可以基于 webhook 实现触发流。
身份验证部分似乎工作正常(我能够创建连接)。使用我的自定义触发器创建流程后,它永远不会被触发。在我这边检查数据时,似乎 Flow 无法正确注册订阅。
如果我导航到流程的管理页面,我会收到以下错误消息。
当我单击修复触发器时,我得到以下详细信息
这是触发器定义:
{
"/AlertRules/{id}/webhooks": {
"x-ms-notification-content": {
"schema": {
"type": "object",
"properties": {
"Title": {
"type": "string",
"description": "Title"
},
"Text": {
"type": "string",
"description": "Text"
},
"Data": {
"type": "array",
"items": {
"$ref": "#/definitions/DataApi.Models.AlertEvent"
},
"description": "Data"
}
}
},
"description": ""
},
"post": {
"responses": {
"201": {
"description": "Created",
"schema": {
"type": "string"
}
}
},
"x-ms-trigger": "single",
"operationId": "NewAlertEvent",
"summary": "When a new Alert Event is created or updated",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string",
"x-ms-visibility": "important",
"x-ms-dynamic-values": {
"operationId": "AlertRules.AlertRule.ListAlertRule",
"value-path": "Id",
"value-collection": "value",
"value-title": "Description"
}
},
{
"name": "body",
"in": "body",
"required": false,
"schema": {
"type": "string",
"x-ms-visibility": "internal",
"title": "",
"x-ms-notification-url": true
},
"x-ms-visibility": "internal"
}
]
}
}
我的删除操作说明
{
"/AlertRuleSubscriptions({Id})": {
"delete": {
"tags": [
"AlertRuleSubscriptions.AlertRuleSubscription"
],
"summary": "Delete entity from AlertRuleSubscriptions",
"operationId": "AlertRuleSubscriptions.AlertRuleSubscription.DeleteAlertRuleSubscription",
"parameters": [
{
"in": "path",
"name": "Id",
"description": "key: Id",
"required": true,
"type": "string",
"format": "uuid",
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
"x-ms-docs-key-type": "AlertRuleSubscription"
},
{
"in": "header",
"name": "If-Match",
"description": "ETag",
"type": "string"
}
],
"responses": {
"204": {
"description": "Success"
},
"default": {
"$ref": "#/responses/error"
}
},
"x-ms-docs-operation-type": "operation"
}
}
}
并且我的 post 操作确实使用与上述删除操作的格式匹配的位置 header 进行回复。
我的问题是:
- 我的触发器声明中缺少什么?
- 如何获取有关订阅创建和 Microsoft Flow 生成的错误的更多详细信息?
在与 Microsoft 进行一些内部讨论后,我们发现了两个主要问题。
首先,我更新了 POST 请求的正文参数以创建对此的订阅。
{
"name": "body",
"in": "body",
"required": false,
"schema": {
"type": "object",
"properties": {
"callbackUrl": {
"type": "string",
"required": true,
"description": "callbackUrl",
"x-ms-notification-url": true,
"x-ms-visibility": "internal"
}
}
}
}
这是因为连接器定义不支持在不使用 JSON 格式的情况下在正文中发送回调 URL,并且因为 Flow 已实现 using the Open API callback specification.
其次,我更新了 API 以支持上述规范。