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
ClAgi
Frequent Visitor

Call Rest for every Row in List

Hello,

this is my first post in this PowerBI Forum Smiley Happy

I'm currently developing a PowerBI Connector with calls to a REST service.

I call the webservice '/contacts' which returns all contacts, but only with
id 1234567890

display Test
path /contacts/1234567890

 

I extracted the path to each contact because i need that to call another webservice to get more details

about the contact.

PathList.PNG

 

And now i don't know how to continue.
My thoughts:

- Call the webservice for each row in the list to get detail information about contact

- expand all records in response with ExpandAllRecords.
- add expanded response to a table

 

Goal:

A table with 12 (this example) rows with detail information about the contact.

 

I know there a function like 

List.Accumulate, Table.AddRows etc etc

but i don't see the big thing with all together.

 

Cheers

2 REPLIES 2
Greg_Deckler
Super User
Super User

I would create a function that did the REST call. Then you could simply create a new column that calls that function with your contact column (Liste) as a parameter.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thank you for your response. That was a good advise !

        deletedAllOthers = Table.SelectColumns(expandedPathColumn,{"$items.$path"}),
        columnRenamed = Table.RenameColumns(deletedAllOthers, {"$items.$path", "path"}),
        newCompleteTable = Table.AddColumn(columnRenamed, "expanded", each S.GetResponseSecondLayer([path])),
        expandedAllColumns = Table.ExpandTableColumn(newCompleteTable, "expanded", 
            Table.ColumnNames(Table.Combine(newCompleteTable[expanded])),
            Table.ColumnNames(Table.Combine(newCompleteTable[expanded])))

I only got one last question. I needed 

Table.RenameColumns(deletedAllOthers, {"$items.$path", "path"}),

because 

S.GetResponseSecondLayer([path])

doesn't take [$items.$path]. That gives me an error. How can i use special character in the [] brackets. I got that problem with another function but i can't use RenameColumns there.

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.