0
votes

I need help with sending workflow information in header/body of calls to custom connector. I am trying to load a drop down list in one of the parameters of a logic app using values returned from an API call. The API end point requires basic workflow information such as the resource group and workflow name which are normally available in headers of http requests from logic app execution.

Normally when I use @{workflow().name} in logic app's json, it is substituted with the workflow name. In case of custom connector, the WDL syntax is passed as is without any transformation.

Here is a simplified swagger json with all relevant sections.

{
    "swagger": "2.0",
    "info": {
        "title": "{{dynamicHostName}}",
        "version": "1.0.0"
    },
    "host": "{{dynamicHostName}}",
    "basePath": "/",
    "schemes": [
        "https"
    ],
    "paths": {
        "/sftpsource": {
            "post": {
                "operationId": "SftpSource",
                "summary": "Sftp as source system",
                "description": "Use Sftp as source system",
                "produces": [
                    "application/json"
                ],
                "consumes": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "name": "params",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "type": "object",
                            "properties": {
                                "hostName": {
                                    "type": "string",
                                    "x-ms-summary": "Host Name",
                                    "x-ms-visibility": "advanced"
                                },
                                "portNumber": {
                                    "type": "string",
                                    "x-ms-summary": "Port Number",
                                    "x-ms-visibility": "advanced"
                                },
                                "userName": {
                                    "type": "string",
                                    "x-ms-summary": "User Name",
                                    "x-ms-visibility": "advanced"
                                },
                                "password": {
                                    "type": "string",
                                    "x-ms-summary": "Password",
                                    "x-ms-visibility": "advanced"
                                },
                                "filePath": {
                                    "type": "string",
                                    "x-ms-summary": "File Path"
                                },
                                "system": {
                                    "type": "string",
                                    "x-ms-visibility": "advanced",
                                    "x-ms-summary": "System",
                                    "x-ms-dynamic-values": {
                                        "operationId": "GetTaggedSystems",
                                        "parameters": {
                                            "workflow-name": "@{workflow().name}"
                                        },
                                        "value-path": "systemId",
                                        "value-title": "systemName"
                                    }
                                }
                            }
                        }
                    }
                ],
                "responses": {
                    "202": {
                        "description": "Request is queued"
                    },
                    "500": {
                        "description": "Server Error"
                    }
                }
            }
        },
        "/taggedSystems" : {
            "get": {
                "operationId": "GetTaggedSystems",
                "summary": "Tagged Systems",
                "x-ms-visibility": "advanced",
                "description": "Get all systems tagged to this flow",
                "parameters": [
                    {
                        "name": "workflow-name",
                        "in": "header",
                        "required": true,
                        "type":  "string"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/TaggedSystems"
                        }
                    },
                    "202": {
                        "description": "Work is still in progress"
                    },
                    "500": {
                        "description": "An error occured while trying to fetch tagged systems."
                    }
                }
            }
        }
    },
    "definitions": {
        "TaggedSystems": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "systemId": {
                        "type": "string"
                    },
                    "systemName": {
                        "type": "string"
                    }
                },
                "required": [
                    "systemId",
                    "systemName"
                ]
            }
        }
    }
}
1

1 Answers

0
votes

You can have an internal parameter defined as header/body where you can pass dynamic expressions of what you need from the workflow environment at the time of execution of the flow.

For complete information regarding the flow, you can pass @{workflow()} as an internal parameter.

Hope it helps.