Microsoft Flow自定义连接器webhook触发器定义和实现:创建流后找不到404

时间:2019-07-03 19:56:21

标签: azure-logic-apps microsoft-flow

我正在尝试为Microsoft Flow中的API创建自定义连接器,以便用户可以基于Webhook实现触发流。 身份验证部分似乎工作正常(我能够创建连接)。使用我的自定义触发器创建流后,就永远不会触发它。在检查我这方面的数据时,似乎Flow无法正确注册订阅
如果导航到该流程的管理页面,则会收到以下错误消息。 There's a problem with the flow's trigger screenshot
单击修复触发器时,我得到以下详细信息not found error,其中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"
      }
}
}

我的发布操作确实会回复一个Location标头,该标头与上述删除操作的格式相匹配。
我的问题是:

  • 触发器声明中缺少什么?
  • 如何获取有关订阅创建和Microsoft Flow生成的错误的更多详细信息?

1 个答案:

答案 0 :(得分:0)

与Microsoft进行了一些内部讨论之后,我们发现了两个主要问题。
首先,我更新了POST请求的body参数,以为此创建订阅。


       {
        "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以支持上述规范。