craig
craig

Reputation: 26262

Use JSON returned by Azure Logic App HTTP connector

I created a HTTP

It's Body property returns a JSON hash:

{
    "data": [
      {
        "id": 123456,
        "fullname": "Last, First",
        "code": null,
        "status": 1,
        "self": "https://api.xxx.com/rest/v1.0/xxx/123456",
        "limits": null,
        "accumulated": null,
        "custom_data_field": [
          {
            "id": 4,
            "label": null,
            "value": null
          },
          {
            "id": 5,
            "label": null,
            "value": null
          },
          {
            "id": 6,
            "label": null,
            "value": null
          }
        ],
        "access_groups": []
      }
    ],
    "meta": {
      "previous": null,
      "total": 1,
      "per_page": 50,
      "next": "https://api.xxx.com/rest/v1.0/xxx?page%5Bnumber%5D=2"
    }
}

I would like to loop each items in the data element.

What is the next step? Initialize variable? Append to an array variable? In either case, what's the syntax to get each element's (e.g. data.fullname) value?

Upvotes: 1

Views: 343

Answers (1)

Hury Shen
Hury Shen

Reputation: 15724

As you described in your question, if you want to loop the items in the data element, you just need to use "Parse JSON" action to parse the whole json string. Such as below screenshot(in screenshot I initialize a variable named "source" which store your json string to simulate your situation) enter image description here

In "Parse JSON" action, please click "Use sample payload to generate schema" button and input your json string, it will generate the schema automatically.

Then add a "For each" loop and use the "data" from "Parse JSON" as the element of the loop. enter image description here

In the "For each", you can use any element in the data as shown in the screenshot above.

Upvotes: 1

Related Questions