Skip to main content

Notifications

Power Automate - Using Connectors
Answered

Trigger Flow from JSON Payload with Key Value Pairs

(0) ShareShare
ReportReport
Posted on by 29

Hi all,

 

I have been trying to connect to JSON webhook payloads from an external tool to append records to a SharePoint list. The issue I am facing is my JSON payload comes in a List style, whereby each data point has a key (the name of the field) and a value (the variable) pairing. These will always be consistently named for all outputs to this Flow, however, I cannot figure out how to access the values as dynamic content under the name of the key.

 

Can someone help me with setting this up so I can use the keys as dynamic content? I am new to webhooks in the Microsoft world. A test sample of the JSON payload is below:

 

{
 "$content-type": "application/x-www-form-urlencoded; charset=UTF-8",
 "$content": "XYZ123xyz321",
 "$formdata": [
 {
 "key": "Alpha_ID",
 "value": "12345"
 },
 {
 "key": "Beta_ID",
 "value": "263014"
 },
 {
 "key": "Gamma",
 "value": "XYZ II"
 },
 {
 "key": "Country",
 "value": "United States"
 },
 {
 "key": "Delta_ID",
 "value": "2630168"
 },
 {
 "key": "Epsilon_Name",
 "value": "Test's Company"
 },
 {
 "key": "Email",
 "value": "test@gmail.com"
 },
 {
 "key": "Zeta",
 "value": "Test Co."
 },
 {
 "key": "Eta_ID",
 "value": "12345"
 },
 {
 "key": "Theta_Name",
 "value": "XYZ"
 },
 {
 "key": "State",
 "value": "California"
 }
 ]
}

 

It is important  to note that:

  • The key-value pairing will not change for this webhook, so I want to be able to use each element
  • The format in the sample reflects the format of these fields, and these will not change (but may be null in some cases where not all data is available)

 

My Flow looks as follows:

AthenaPM_0-1615548764574.png

 

Any and all help will be greatly appreciated!

  • DamoBird365 Profile Picture
    DamoBird365 8,942 on at
    Re: Trigger Flow from JSON Payload with Key Value Pairs

    Hi @AthenaPM 

     

    I assumed that these keys would vary and your example was theoritical but if they are always in the same position in the array, you could use the expression:

    variables('123')?['$formdata']?[0]?['value'] = 12345
    variables('123')?['$formdata']?[1]?['value']
    variables('123')?['$formdata']?[N]?['value']
    etc
    Where N is the position, starting from 0.
     
    Damien
  • AthenaPM Profile Picture
    AthenaPM 29 on at
    Re: Trigger Flow from JSON Payload with Key Value Pairs

    Hi @DamoBird365 ,

     

    Thanks for the help on this. I haven't had a chance to fully get back into this particular project due to higher priorities elsewhere. I did quickly test this out and it seems to work, and I thought I had accepted the solution earlier this week but the Power Community website is always super buggy when I am on it.

     

    I kind of wish there was a slightly simpler way to turn it into variables (in one connector), however, if it has to be this way, it will be.

     

    Thanks mate,

    Max

  • DamoBird365 Profile Picture
    DamoBird365 8,942 on at
    Re: Trigger Flow from JSON Payload with Key Value Pairs

    Thank you @AthenaPM 

     

    You were my 100th solution!

     

    DamoBird365_0-1615968421827.png

    😀😀😀😀😀😀😀😀😀😀😀😀

  • DamoBird365 Profile Picture
    DamoBird365 8,942 on at
    Re: Trigger Flow from JSON Payload with Key Value Pairs

    Hi @AthenaPM 

     

    How are you getting on?  If you need more help then please let me know.

     

    If my post has helped, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien

  • Verified answer
    DamoBird365 Profile Picture
    DamoBird365 8,942 on at
    Re: Trigger Flow from JSON Payload with Key Value Pairs

    Hi @AthenaPM 

     

    For the purpose of this, I've stuck your json into an array like so :

    DamoBird365_0-1615625228602.png

     

    Then I have used a compose to obtain the $formdata element of the array and finally the parse action.  The easiest way to get a sample payload for the Parse JSON is to run the flow with the schema set to {} and then grab the history output from the earlier compose.

     

    DamoBird365_1-1615625306881.png

    This then allows me to select the key and value items as dynamic content. 

     

    DamoBird365_2-1615625659824.png

     

    You could then use a filter if you are looking for a specific key.

    DamoBird365_1-1615625911264.png

     

    DamoBird365_0-1615625900516.png

     

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,343

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,703

Leaderboard

Featured topics