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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
ViniDreamit
Frequent Visitor

Get more data with API with more ID client

Hello, 

 

I have this code, but I wanna get all date of my students,at once. With this code below I get one-per-one

 

let
url = "http://webservices.sponteweb.com.br/WSApiSponteRest/api/students",

Body = "{""student_id"": ""61""}",

source = Json.Document(Web.Contents(url, [Headers = [#"Content-Type"="application/json", #"Accept"="application/json", #"api_key"="XXXXX"], Content = Text.ToBinary(Body)]))
in
source

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @ViniDreamit 

 

You can call the API repeatedly using List.Transform as is shown in this similar question

 

Solved: Re: DATA for multiple years - Microsoft Power BI Community

 

 

For you, you could use code liek this heer the Student ID's are specified in a list - this example just gets ID's 1 to 5.  Change this accordingly.

let
    url = "http://webservices.sponteweb.com.br/WSApiSponteRest/api/students",
    StudentIDs = {1 .. 5},

    GetWebPage = (StudentID) => let

        Body = "{""student_id"": """ & StudentID & """}",

        Source = Json.Document(Web.Contents(url, [Headers = [#"Content-Type"="application/json", #"Accept"="application/json", #"api_key"="XXXXX"], Content = Text.ToBinary(Body)]))
        
    in Source,
    
    
    WebPages = List.Transform(StudentIDs, each GetWebPage(Text.From(_))),
    #"Converted to Table" = Table.FromList(WebPages, Splitter.SplitByNothing(), null, null, ExtraValues.Error)    
    
in
    #"Converted to Table"

 

Or if you have a column with the sudent ID's, that coudl be passed into the function to call the API.  If this is the case please provide some sample data and/or an image of your table so I can see how it is structured.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

3 REPLIES 3
ViniDreamit
Frequent Visitor

Thanks a lot Phil!! It's working very well! 

PhilipTreacy
Super User
Super User

Hi @ViniDreamit 

 

You can call the API repeatedly using List.Transform as is shown in this similar question

 

Solved: Re: DATA for multiple years - Microsoft Power BI Community

 

 

For you, you could use code liek this heer the Student ID's are specified in a list - this example just gets ID's 1 to 5.  Change this accordingly.

let
    url = "http://webservices.sponteweb.com.br/WSApiSponteRest/api/students",
    StudentIDs = {1 .. 5},

    GetWebPage = (StudentID) => let

        Body = "{""student_id"": """ & StudentID & """}",

        Source = Json.Document(Web.Contents(url, [Headers = [#"Content-Type"="application/json", #"Accept"="application/json", #"api_key"="XXXXX"], Content = Text.ToBinary(Body)]))
        
    in Source,
    
    
    WebPages = List.Transform(StudentIDs, each GetWebPage(Text.From(_))),
    #"Converted to Table" = Table.FromList(WebPages, Splitter.SplitByNothing(), null, null, ExtraValues.Error)    
    
in
    #"Converted to Table"

 

Or if you have a column with the sudent ID's, that coudl be passed into the function to call the API.  If this is the case please provide some sample data and/or an image of your table so I can see how it is structured.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


I don't have a list, but it's work perfectly!  
Thanks a lotttt

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Kudoed Authors