cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
michaelBurch
Frequent Visitor

Trying to parse JSON data to Excel in a Flow. Unable to get past the Initialize variable

Hi all,

Here is my challenge.  As I preface every message I submit, I’m new to the PowerPlatform arena and far from a developer in any sense.  So I apologize for the remedial question.  Here is my use case and challenge – Use case:  We are being asked to create an app that can call the YouTube API and return specific information for review.  The challenge I currently having is on the Flow; I’m able to pass the data from the HTTP REST API invocation to a Response.  The issue now is on parsing this data into an Excel table.  I have searched for a method and have been able to derive at:

  • PowerApps trigger
  • HTTPS REST API invoke
  • Response (JSON Schema)
  • Initialize variable (This is where I’m stuck)
  • Apply to each
    • Parse JSON
    • Add rows to Excel

Where I am stuck is passing the data from the Response to the Initialize variable to the Parse JSON.  I’ve been able to directly add Array values directly to the Initialize variable to kind of ‘synthesize’ the process successfully, but I need to be able to these come from the Response above.  If I remove the manually inserted data from the Initialize variable Value area and add Dynamic content from the Body of the HTTP REST API invoke I get an error on test:  The variable 'Data' of type 'Array' cannot be initialized or updated with value ‘ {the json string of data}’ of type 'Object'. The variable 'Data' only supports values of types 'Array'.

Here is the visual details:

michaelBurch_0-1594500898047.png

 

 

 

michaelBurch_1-1594500898052.png

 

michaelBurch_2-1594500898057.png

 

michaelBurch_3-1594500898060.png

 

 

Initialize variable error:

michaelBurch_4-1594500898070.png

 

 

Any guidance or advice would be greatly appreciated and thank you in advance

Michael B

2 REPLIES 2
efialttes
Super User
Super User

Hi!

Sorry I got lost with the purpose of the 'Data' variable

I assume you inspected the outputs from the Youtube API and ensured it provides an array as its response, right?

If so, you should assign this array as 'Apply to each' input

Now, I assume the array has objects as elements, you can just copy one of these elements, then on 'PArse JSON' click on 'Generate for sample' and paste the sample object elment there

 

But, if you wanna keep this 'Dat variable approach for testing purposes... I would try to initialize a variable of type object, let's call it 'DataObject' assign the single object element you are dealing in your current 'Data' variable, then initialize variable of type array, and use the following WDL expression

createArray(variables('DataObject'))

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Thank you for your response @efialttes !

I'm really struggling with this one 😞 - I removed the Initialize Variable, added the object sample to the Parse JSON to have it generate the schema, but now getting the following error at the Parse JSON when testing:

ExpressionEvaluationFailed. The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@body('HTTP')' is of type 'Object'. The result must be a valid array.

 

Sorry to ask for all the help on this

 

Current flow after changes:

michaelBurch_0-1594657846925.png

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (2,192)