0

We are building nested logic apps where a logic app will call another logic app to aggregate some data.
Currently we have Logic Apps A, B and C all being setup with a GET request.
Logic App ABC that aggreagtes all the data will be exposed by the API over a GET request and internally call A to C to gather all the data.
When we use Postman however we get an error message:

{
  "error": {
    "code": "TriggerRequestMethodNotValid",
    "message": "The HTTP method for this request is not valid: expected 'Get' and actual 'POST'."
  }
}

Which would imply that ABC calls A with a POST instead of a GET.
We've got the hunch, that this is due to us calling the Logic App with a body element.
We temporarly fixed the problem by setting all logic app calls to POST, but we would like to avoid this, since we might expose A as system layer API and would like to keep it as a GET.
The code for A:

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Filter_is_null": {
                "actions": {
                    "Get_locations": {
                        "inputs": {
                            "host": {
                                "connection": {
                                    "name": "@parameters('$connections')['salesforce']['connectionId']"
                                }
                            },
                            "method": "get",
                            "path": "/datasets/default/tables/@{encodeURIComponent(encodeURIComponent('Location__c'))}/items"
                        },
                        "runAfter": {},
                        "type": "ApiConnection"
                    },
                    "Response": {
                        "inputs": {
                            "body": "@body('Get_locations')?['value']",
                            "statusCode": 200
                        },
                        "kind": "Http",
                        "runAfter": {
                            "Get_locations": [
                                "Succeeded"
                            ]
                        },
                        "type": "Response"
                    }
                },
                "else": {
                    "actions": {
                        "Get_locations_filtered": {
                            "inputs": {
                                "host": {
                                    "connection": {
                                        "name": "@parameters('$connections')['salesforce']['connectionId']"
                                    }
                                },
                                "method": "get",
                                "path": "/datasets/default/tables/@{encodeURIComponent(encodeURIComponent('Location__c'))}/items",
                                "queries": {
                                    "$filter": "@triggerBody()?['filter']"
                                }
                            },
                            "runAfter": {},
                            "type": "ApiConnection"
                        },
                        "Response_error": {
                            "inputs": {
                                "body": {
                                    "component": "sf-locations-get",
                                    "message": "bad request - validate filter"
                                },
                                "statusCode": 400
                            },
                            "kind": "Http",
                            "runAfter": {
                                "Get_locations_filtered": [
                                    "Failed"
                                ]
                            },
                            "type": "Response"
                        },
                        "Response_filtered": {
                            "inputs": {
                                "body": "@body('Get_locations_filtered')?['value']",
                                "statusCode": 200
                            },
                            "runAfter": {
                                "Get_locations_filtered": [
                                    "Succeeded"
                                ]
                            },
                            "type": "Response"
                        }
                    }
                },
                "expression": {
                    "and": [
                        {
                            "equals": [
                                "@triggerBody()?['filter']",
                                "@null"
                            ]
                        }
                    ]
                },
                "runAfter": {},
                "type": "If"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "request": {
                "inputs": {
                    "method": "GET",
                    "schema": {
                        "properties": {
                            "filter": {
                                "type": "string"
                            }
                        },
                        "type": "object"
                    }
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "parameters": {
        "$connections": {
        }
    }
}

Image of A for reference: API 'A'

Image of ABC for reference: API 'ABC'

Is there a possibility to call nested logic apps, containing a body using GET?

Peter
  • 1,844
  • 2
  • 31
  • 55

2 Answers2

1

You can call another logic app from one logic app and pass a body to it. If you are calling another logic app which triggers with a http request the method expected is generally POST. Try to pass the body and check if that helps in your case.

enter image description here

Please refer to this document

You may also check these and see if these suffices your requirement:

https://www.serverlessnotes.com/docs/nested-logic-apps

https://blog.sandro-pereira.com/2016/04/19/the-ability-to-call-nested-logic-apps-directly-from-logic-apps-designer/

1

Using a body in a GET request breaks the internet.

In short, this breaks the semantics that a resource-uri in combination with the headers is the cacheable key. When you add a body to the GET request, the caching ability is removed.

It is by design that you cannot and should not add a body to a GET request.

You should rethink your call setup and when you need to send a body, then you need to use other HTTP methods that do not break proper semantics. e.g. POST, PUT, etc.

More info: https://stackoverflow.com/a/983458/1581925

twildeman
  • 599
  • 5
  • 10