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:
My Flow looks as follows:
Any and all help will be greatly appreciated!
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:
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
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
Hi @AthenaPM
For the purpose of this, I've stuck your json into an array like so :
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.
This then allows me to select the key and value items as dynamic content.
You could then use a filter if you are looking for a specific key.
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