skip to Main Content

I’m making an http request to the api using the below details but I’m getting the 400 error with the above message.
On postman it is working fine, but when I try it on Azure Logic Apps, it’s not going through. I’ve checked couple of similiar posts but still no luck.

Any assistance in pointing to the right direction is appreciated.

Headers:

{
  "Accept": "application/json; odata.metadata=minimal",
  "Authorization": "Token xxxxx",
  "Content-Type": "application/json; odata=minimalmetadata; charset=utf-8"
}

Body:

{
  "ExtractionRequest": {
    "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.IntradayPricingExtractionRequest",
    "ContentFieldNames": [
      "RIC",
      "Ask Price",
      "Asset Type",
      "Bid Price",
      "Currency Code",
      "Exchange Code",
      "High Price",
      "Instrument ID",
      "Instrument ID Type",
      "Low Price",
      "Open Price",
      "Previous Close Date",
      "Previous Close Price",
      "Security Description",
      "Settlement Price",
      "Trade Date",
      "User Defined Identifier",
      "Volume"
    ],
    "IdentifierList": {
      "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",  
      "InstrumentIdentifiers": [
        { 
            "Identifier": "438516AC0", 
            "IdentifierType": "Cusip" 
        },
      { 
            "Identifier": "IBM.N", 
            "IdentifierType": "Ric" 
        },
        {
            "Identifier": "JPYUSD=R",
            "IdentifierType": "Ric"
        },
        {
            "Identifier": "USDAUD=R",
            "IdentifierType": "Ric"
        },
        {
            "Identifier": "EURGBP=R",
            "IdentifierType": "Ric"
        },
        {
            "Identifier": "EURZAR=R",
            "IdentifierType": "Ric"
        },
        {
            "Identifier": "ZARUSD=R",
            "IdentifierType": "Ric"
        },
        {
            "Identifier": "USDZAR=R",
            "IdentifierType": "Ric"
        }
 
      ]
    },
    "Condition": { "ScalableCurrency": true }
  }
}

Response:

{
  "error": {
    "message": "Malformed request payload: Syntax error at Line 1, Char 1: expected valid json array or json object "
  }
}

See below images

enter image description here
enter image description here

2

Answers


  1. I see that in your body you have used json(object). In logic app json function only takes xml or string and it converts it into json.

    One way to send that Object is by using below design:

    Initialize the json into string variable:

    enter image description here

    then parse json with below schema:

    {
        "type": "object",
        "properties": {
            "ExtractionRequest": {
                "type": "object",
                "properties": {
                    "@@odata.type": {
                        "type": "string"
                    },
                    "ContentFieldNames": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "IdentifierList": {
                        "type": "object",
                        "properties": {
                            "@@odata.type": {
                                "type": "string"
                            },
                            "InstrumentIdentifiers": {
                                "type": "array",
                                "items": {
                                    "type": "object",
                                    "properties": {
                                        "Identifier": {
                                            "type": "string"
                                        },
                                        "IdentifierType": {
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "Identifier",
                                        "IdentifierType"
                                    ]
                                }
                            }
                        }
                    },
                    "Condition": {
                        "type": "object",
                        "properties": {
                            "ScalableCurrency": {
                                "type": "boolean"
                            }
                        }
                    }
                }
            }
        }
    }
    

    enter image description here

    In http action send body this way:

    {"test":@{body('Parse_JSON')}}
    

    enter image description here

    In Logic app @ is taken as a function or calling an action in code.

    Output:

    enter image description here

    Login or Signup to reply.
  2. Step 1: Place your JSON content into a string variable:

    String variable

    Step 2: Use your string variable in the body of your HTTP request, converting it to JSON first e.g. json(variables('JSON_in_string')):

    HTTP request body

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