Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jh_dempsey
Frequent Visitor

Loop through list a to perform a REST API call and produce a table for each item in the list

Hi All

 

I am creating our own custom data connector to retrieve data stored in some custom software we had developed for us.

I can get to the data via a REST API

 

One of the REST API calls, if I provide an "assetTypeCode" parameter, will return me all records in the database for that particular asset type.

 

I have the asset types I want to extract in a list

eg {"DGMH","LLLP","RRVS"}

 

I need my data connector to loop through this list, make a REST API call using the asset code, and then create me a table containing all of the returned asset records.

 

This means for the example above, I should end up with 3 tables being produced. one for DMH, one for LLLP, and one for "RRVS"

 

The code needs to be dynamic, so if I add a 4th asset type to my list, i want the code to automatically produce me 4 tables.

 

Is this possible in Power BI? All m programming experience is in te .NET languages so I'm struggling with not being able to do loops!

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @jh_dempsey 

Value the answer from mahoneypat, here is a thread how to loop web data with power query in details:

https://community.powerbi.com/t5/Desktop/script-running-looping-URLs-and-get-data/td-p/135980

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

mahoneypat
Employee
Employee

Yes.  Just start with a query that has your assettypecodes in a table (so you can refresh it to add/remove more in future), and then add a custom column that makes your web call for each.  For example,  Web.Contents("Your Base URL?assettypecode=" & [AssetTypeCode] & "other url parameters if needed").  This will return a column of Tables that you can expand to combine all the data.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors