skip to Main Content

I am trying to create my first Logic app to filter a query from a third party API service.
The third party API responds with both a SearchSummary (Object) and Data (Array) items.

I want to return only the Data array in my response, but keep getting an error:

{
    "error": {
        "code": "NoResponse",
        "message": "The server did not receive a response from an upstream server. Request tracking id '08584773567277623430271089584CU00'."
    }
}

If I change the variable assignment from @body('Parse_JSON')?['Data'] to @body('Parse_JSON')?['SearchSummary'] then the SearchSummary returns fine. I’ve tried appending .items to the value but that also doesn’t help.

When I return length(@body('Parse_JSON')?['Data']) in my response, it does return an accurate number so there are definitely items there.

Can someone explain what I’m doing wrong?

Here is the code view from my app:

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Create_Contacts_Array": {
                "inputs": {
                    "variables": [
                        {
                            "name": "OnlineContacts",
                            "type": "array",
                            "value": "@body('Parse_JSON')?['Data']"
                        }
                    ]
                },
                "runAfter": {
                    "Parse_JSON": [
                        "SUCCEEDED"
                    ]
                },
                "type": "InitializeVariable"
            },
            "HTTP": {
                "inputs": {
                    "headers": {
                        "ApiToken": "XXX"
                    },
                    "method": "GET",
                    "uri": "https://api.companysearch.com/v1/data?query=X+Y+Z"
                },
                "runAfter": {},
                "type": "Http"
            },
                        "Parse_JSON": {
                "inputs": {
                    "content": "@body('HTTP')",
                    "schema": {
                        "properties": {
                            "Data": {
                                "items": {
                                    "properties": {
                                        "MEMBERSHIP_DATA": {
                                            "items": {
                                                "properties": {
                                                    "companyId": {
                                                        "type": [
                                                            "string",
                                                            "null"
                                                        ]
                                                    },
                                                    "companyName": {
                                                        "type": [
                                                            "string",
                                                            "null"
                                                        ]
                                                    },
                                                    "dept": {
                                                        "type": [
                                                            "string",
                                                            "null"
                                                        ]
                                                    },
                                                    "endDate": {
                                                        "type": [
                                                            "string",
                                                            "null"
                                                        ]
                                                    },
                                                    "startDate": {
                                                        "type": [
                                                            "string",
                                                            "null"
                                                        ]
                                                    },
                                                    "status": {
                                                        "type": [
                                                            "string",
                                                            "null"
                                                        ]
                                                    },
                                                    "title": {
                                                        "type": [
                                                            "string",
                                                            "null"
                                                        ]
                                                    }
                                                },
                                                "type": "object"
                                            },
                                            "type": "array"
                                        },
                                        "birthdate": {
                                            "type": [
                                                "string",
                                                "null"
                                            ]
                                        },
                                        "dirId": {
                                            "type": [
                                                "string",
                                                "null"
                                            ]
                                        },
                                        "firstName": {
                                            "type": [
                                                "string",
                                                "null"
                                            ]
                                        },
                                        "lastName": {
                                            "type": [
                                                "string",
                                                "null"
                                            ]
                                        },
                                        "middleName": {
                                            "type": [
                                                "string",
                                                "null"
                                            ]
                                        }
                                    },
                                    "type": "object"
                                },
                                "type": "array"
                            },
                            "SearchSummary": {
                                "properties": {
                                    "DatabaseInfo": {
                                        "properties": {
                                            "IndexationDate": {},
                                            "ReleaseNumber": {
                                                "type": "string"
                                            },
                                            "UpdateDate": {
                                                "type": "string"
                                            },
                                            "UpdateNumber": {
                                                "type": "string"
                                            },
                                            "VersionNumber": {
                                                "type": "string"
                                            }
                                        },
                                        "type": "object"
                                    },
                                    "Offset": {
                                        "type": "integer"
                                    },
                                    "RecordsReturned": {
                                        "type": "integer"
                                    },
                                    "Sort": {},
                                    "TotalRecordsFound": {
                                        "type": "integer"
                                    }
                                },
                                "type": "object"
                            }
                        },
                        "type": "object"
                    }
                },
                "runAfter": {
                    "HTTP": [
                        "SUCCEEDED"
                    ]
                },
                "type": "ParseJson"
            },
            "Response": {
                "inputs": {
                    "body": "@variables('OnlineContacts')",
                    "statusCode": "@outputs('HTTP')?['statusCode']"
                },
                "kind": "Http",
                "runAfter": {
                    "Create_Contacts_Array": [
                        "SUCCEEDED"
                    ]
                },
                "type": "Response"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "triggers": {
            "When_a_HTTP_request_is_received": {
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "kind": "Stateless"
}

Here is a sample JSON payload that the HTTP request retrieves:

{
    "SearchSummary": {
        "TotalRecordsFound": 48,
        "Offset": 0,
        "RecordsReturned": 48,
        "DatabaseInfo": {
            "ReleaseNumber": "43",
            "UpdateNumber": "431",
            "UpdateDate": "2024-08-20T00:00:00",
            "VersionNumber": "129.00",
            "IndexationDate": null
        },
        "Sort": null
    },
    "Data": [
        {
            "birthdate": "1950-06-01T00:00:00",
            "firstName": "Ian",
            "middleName": "Charlie",
            "lastName": "Jones",
            "dirId": "P003577888",
            "MEMBERSHIP_DATA": [
                {
                    "companyId": null,
                    "companyName": null,
                    "startDate": null,
                    "status": null,
                    "endDate": null,
                    "title": null,
                    "dept": null
                }
            ]
        },
        {
            "birthdate": "1919-05-11T00:00:00",
            "firstName": "Dorothy",
            "middleName": "June",
            "lastName": "Perkins",
            "dirId": "P003890700",
            "MEMBERSHIP_DATA": [
                {
                    "companyId": null,
                    "companyName": null,
                    "startDate": null,
                    "status": null,
                    "endDate": null,
                    "title": null,
                    "dept": null
                }
            ]
        },
        {
            "birthdate": "1947-11-09T00:00:00",
            "firstName": "Paul",
            "middleName": "Dean",
            "lastName": "Doe",
            "dirId": "P003890600",
            "MEMBERSHIP_DATA": [
                {
                    "companyId": "GB04969800",
                    "companyName": "Acme Ltd 1",
                    "startDate": "2020-04-15T00:00:00",
                    "status": "Current",
                    "endDate": null,
                    "title": "Director",
                    "dept": "Board of Directors; Senior management"
                },
                {
                    "companyId": "GB07346800",
                    "companyName": "Acme Ltd 2",
                    "startDate": "2010-08-16T00:00:00",
                    "status": "Current",
                    "endDate": null,
                    "title": "Director",
                    "dept": "Board of Directors; Senior management"
                },
                {
                    "companyId": "GB06741800",
                    "companyName": "Acme Ltd 3",
                    "startDate": "2008-11-04T00:00:00",
                    "status": "Current",
                    "endDate": null,
                    "title": "Director",
                    "dept": "Board of Directors; Senior management"
                }
            ]
        }
    ]
}

2

Answers


  1. Can’t assign array from JSON to a new variable and return in reponse in Azure Logic App

    It works fine for me using below design even with 3 membership data:

    enter image description here

    In Compose stored your given sample data with 3 MEMBERSHIP_DATA . And my Parse_Json schema is:

    {
        "type": "object",
        "properties": {
            "SearchSummary": {
                "type": "object",
                "properties": {
                    "TotalRecordsFound": {
                        "type": "integer"
                    },
                    "Offset": {
                        "type": "integer"
                    },
                    "RecordsReturned": {
                        "type": "integer"
                    },
                    "DatabaseInfo": {
                        "type": "object",
                        "properties": {
                            "ReleaseNumber": {
                                "type": "string"
                            },
                            "UpdateNumber": {
                                "type": "string"
                            },
                            "UpdateDate": {
                                "type": "string"
                            },
                            "VersionNumber": {
                                "type": "string"
                            },
                            "IndexationDate": {}
                        }
                    },
                    "Sort": {}
                }
            },
            "Data": {
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "birthdate": {
                            "type": "string"
                        },
                        "firstName": {
                            "type": "string"
                        },
                        "middleName": {
                            "type": "string"
                        },
                        "lastName": {
                            "type": "string"
                        },
                        "dirId": {
                            "type": "string"
                        },
                        "MEMBERSHIP_DATA": {
                            "type": "array",
                            "items": {
                                "type": "object",
                                "properties": {
                                    "companyId": {},
                                    "companyName": {},
                                    "startDate": {},
                                    "status": {},
                                    "endDate": {},
                                    "title": {},
                                    "dept": {}
                                },
                                "required": [
                                    "companyId",
                                    "companyName",
                                    "startDate",
                                    "status",
                                    "endDate",
                                    "title",
                                    "dept"
                                ]
                            }
                        }
                    },
                    "required": [
                        "birthdate",
                        "firstName",
                        "middleName",
                        "lastName",
                        "dirId",
                        "MEMBERSHIP_DATA"
                    ]
                }
            }
        }
    }
    

    Make sure you use above Schema as it worked for me.
    Output:

    enter image description here

    Login or Signup to reply.
  2. Your workflow fails because it is stateless, not stateful, and the content size of your variable OnlineContacts exceeds the maximum allowed size of 1024 bytes. Please refer to https://docs.microsoft.com/en-us/azure/logic-apps/edit-app-settings-host-settings#variables to update the maximum configured value.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search