web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Defining value for dyn...
Power Automate
Unanswered

Defining value for dynamic content

(0) ShareShare
ReportReport
Posted on by 85

Hi,

 

I have a custom API connector which retreives a dump of json data. I would like to take the results and store it in SQL. the connector works fine and it retreives the data, but im stuck with defining the next step. Here are the first two examples of the results (the list goes on):

{
"user_id": 4200,
"user_display": "0658_Test1"
},
{
"user_id": 2338,
"user_display": "10014_Test2"
}

 

 

In step 2, i would like to run a For-Each to cycle through all returned results and perform an action. I this action, I would need to specify the value of "user_display" (e.g. 0658_Test1) and perform an action. That said, i have two questions

 

  1. How do i extract the "user_display" value to hand it to the next step? I was trying to play with "split" but no lunk. 
  2. How does Flow define the "For-Each"? Meaning. how does it decide what to proccess next? In my case, i need it to perform the For-Each action for each user_display. So start with 0658_Test1 move to the next "user_display" and perform the action for 10014_Test2, and so on..

Here is a screenshot of what i have so far.

 Screenshot

Categories:
I have the same question (0)
  • JO-30091535-0 Profile Picture
    85 on at

    I've actually just tried the Json parser, but its failing for me as the Json step, its saying "ValidationFailed". Im not sure what the issue is. Here are the details.

     

    Data return by API:

    [
    null,
    [
    {
    "user_id": 4200,
    "user_display": "10658_Test1"
    },
    {
    "user_id": 2338,
    "user_display": "10014_Test2"
    }
    ]
    ]

     

    Sample payload to generate Scheme

    {
    "user_id": 4200,
    "user_display": "10658_Test1"
    }

     

    Generated Scheme

    {
    "type": "object",
    "properties": {
    "user_id": {
    "type": "number"
    },
    "user_display": {
    "type": "string"
    }
    }
    }

     

     

  • v-yuazh-msft Profile Picture
    on at

    Hi @ JoeO,

     

     

    I have made a test on my side, please take a try to create a flow as screenshot below:

    Capture.PNG

    The expression in the value field of "Initial variable 2" action as below:

    first(skip(variables('OriginalArray'),1))
     
    The expression in the "Compose" action as below:
    items('Apply_to_each')?['user_display']

     

    The flow would run successfully as below:

    Capture.PNG

     

    Regards,
    Alice Zhang

  • JO-30091535-0 Profile Picture
    85 on at

    Hi Alice,

     

    Thank you so much for the response and assistance. My issue with your solution is that in the first initialize var step, i need to reference the "body" output of the previous step. Im making an API call and obtaining dynamic data. The data I provided is a sample of the output obtained. When im trying your solution, I don’t see the “body” dynamic content when using an array type. See screenshot.

     

    Screenshot

  • v-yuazh-msft Profile Picture
    on at

    Hi @JoeO,

     

    Could you please share more details about the custom API that you created?

     

    Please check if you have created the custom API correctly and the api could return the dynamic content of itself.

     

    You could refer to link below to learn more about create custom connectors.

    https://docs.microsoft.com/en-us/connectors/custom-connectors/

     

    Regards,
    Alice Zhang

  • JO-30091535-0 Profile Picture
    85 on at

    Hi Alice,

    Sorry about my delayed response. I was out of the office. I actually got it working. As mentioned, when using the solution you provided, i needed to reference in the first initialize the "body" of the previous step - as dynamic content. I was unable to select when the type was array. As a workaround, i changed it to string, selected the dynamics content, and then changed it back to Array. I tested and was successful. See video below.
    https://imgur.com/a/c17WY

    Also, in an unrelated matter, is it possible to use the gateway to connect to a custom API connector? I dont want to expose https. If not, then is it possible to connect flow to the API Via an Azure VPN to the private network? If not, is there a list of Microsoft IP’s used by flow which I could add to my firewall?

    Lastly, is it possibly to configure the flow custom connector to ignore certificate errors?

  • JO-30091535-0 Profile Picture
    85 on at

    Alice,

     

    I actually still have an issue. The For-Each action needs to run another action which retrieves new json data (different data than in the previous step). To explain what im tying to perform: Im making an API call to a system to list all users, I then take each user (the user_display mentioned above) and make a second call to get the details about the user. Finally, I would like to take the details and store it in SQL. The second API call outputs the same type of json data (with the Null) which I need to parse. I tried using the same solution, but it says: "The operation 'Initialize variable' can only be used at top level."

     

  • JO-30091535-0 Profile Picture
    85 on at

    I need to use a compose, but i cant figure out how to retrieve the data that i need. For example, take a look at the screenshot below, lets say i wish to grab the "group_id" and "group_label" and store in SQL. I tried playing with item an trigger expressions, but i cant figure it out. 

     

     Microsoft FlowGetLivUser.png

  • JO-30091535-0 Profile Picture
    85 on at

    Ok, i figured it out using two composes. My only remaining question, do i need a separate compose for each item I wish to retrieve? The output of the JSON array contains multiple sections and each section contains multiple items. I have it working for one item, but would like to add many more items on the same compose (if possible). The first compose is used to grab the json body objects (omitting the Null section), and the second, to grab the value of one specific item

     

    First Compose (Name: Get_Liv_Users_Array):
    first(skip(body('Get_Liv_User'),1))

     

    Second Compose:
    actionOutputs('Get_Liv_Users_Array')[GroupName]['GrpName2']['item1']

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard