0
votes

Have built an Azure logic app with a HTTP trigger that receives a JSON file, provides a response, then attempts to send the payload to a Service Bus queue. Kept getting an status 400 error, so tried adding a parse JSON step, however am getting an invalid template per shot below. Azure logic app

parse JSON error The response is working correctly, with the payload being correctly displayed at the initiating website. successful response

The JSON data in the schema is as follows. EDIT: Revised schema to include "null" per Rick's suggestion below.

{
"items": {
    "properties": {
        "Entry Price": {
            "type": [
                "string",
                "null"
            ]
        },
        "Exit Price": {
            "type": [
                "string",
                "null"
            ]
        },
        "Gain $": {
            "type": [
                "string",
                "null"
            ]
        },
        "New Stop": {
            "type": [
                "string",
                "null"
            ]
        },
        "ReceivedDate": {
            "type": [
                "string",
                "null"
            ]
        },
        "ReceivedTime": {
            "type": [
                "string",
                "null"
            ]
        },
        "Status": {
            "type": [
                "string",
                "null"
            ]
        },
        "Stop": {
            "type": [
                "string",
                "null"
            ]
        },
        "Symbol": {
            "type": [
                "string",
                "null"
            ]
        },
        "Tranche": {
            "type": [
                "string",
                "null"
            ]
        }
    },
    "required": [
        "Symbol",
        "Status",
        "ReceivedDate",
        "ReceivedTime"
    ],
    "type": "object"
},
"type": "array"

} I have spent days looking at forums and trying a number of suggested fixes, however am unable to get the app to execute without error.

Appreciate any ideas or suggestions to fix. Thanks.

1

1 Answers

0
votes

It looks like you are passing in a null value for the property content, while the schema has it as a required property.

You can solve this by changing the definition in the schema for content to be as follows:

"content":{
  "type":[
    "string",
    "null"
  ]
}

More information (and source) here: Parsing JSON with null-able properties in Logic Apps

There is also default values, that could be considered, but everything depends on the context your logic app operates in.