Tuesday, February 20, 2024

How to retrieve the value from array or list in logic app

 

As per my requirement, I need to trigger third-party API. Upon a successful response, the API provides an array containing the Account ID. I have to retrieve this value without utilizing a for-each loop.

 I have successfully met this requirement using the following approach. 


Below is the JSON format:

"OrderLines": [
    {
	"line": "1",
	"orderedAccount": {
	    "Reference": {
		"AccountID": "ABC1234"
		}
	    }
    }
]

I have used the Below expression:

"body('HTTP')?['OrderLines']?[0]?['orderedAccount']?['Reference']?['AccountID']"


"OrderLines": [
    {
	"Reference": {
	    "AccountID": "ABC1234"
	   }
    },
    {
	"Reference": {
	    "AccountID": "ABC1235"
	    }
    }
],

I have used the Below expression:

"body('HTTP')?['OrderLines']?[0]?['Reference']?['AccountID']"

Output: ABC1234.


Keep Daxing!!