Microsoft Flow Custom Connector webhook trigger definition and implementation : 404 not found after flow creation

半腔热情 提交于 2019-12-24 08:29:09

问题


I'm trying to create a custom connector for my API in Microsoft Flow so users can trigger flows based on a webhook implementation. The authentication part seems to be working properly (I'm able to create connections). After creating a flow using my custom trigger, it never gets triggered. When checking the data on my end it seems that Flow was never able to register the subscription properly.
If I navigate to the management page for the flow, I get the following error message.
When I click on fix the trigger I get the following details where the Id parameter matches the id of the resource we're trying to subscribe to.
Here is the trigger definition:

{
"/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"
          }
        ]
      }
}

The description of my delete operation

{
"/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"
      }
}
}

And my post operation does reply with a Location header which matches the format of the delete operation described above.
My questions are:

  • What is missing in my trigger declaration?
  • How can I get more details on the subscription creation and the error Microsoft Flow is generating?

回答1:


After some internal discussions with Microsoft we found two main issues.
First I updated the body parameter of the POST request to create the subscription to this.


       {
        "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"
          }
         }
        }
       }

That is because the connector definitions don't support sending the callback URL in the body without using JSON formatting and because Flow was implemented using the Open API callback specification.

Second I updated my API to support the specification mentioned above.



来源:https://stackoverflow.com/questions/56877126/microsoft-flow-custom-connector-webhook-trigger-definition-and-implementation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!