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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
stribor45
Post Prodigy
Post Prodigy

Power Query - Blank Query - API Call Service Refresh

I have this piece of code where I call external API to get some data but an issue I am having is that once I publish this to Power BI service if fails to refresh you to dynamic data source etc. However, I tried to follow Chriss's tutorial on resolving this problem with no luck.  When I call it by using the whole URL, I get data, so i am wondering if I am breaking it down correctly.

 

This URL works https://url.com/api/something/calls?limit=3&start=0

 

 

 

let
    headers = [#"Content-Type" = "application/json", #"Accept"="application/json"],
    
    getJson = (url) => 
      let
        Source = Json.Document(Web.Contents(url, [RelativePath = "pokemon?", Query=[limit="100", offset="0"], Headers = headers]))

      in 
        Source,
    
    data = getJson("https://pokeapi.co/api/v2")
in
    data

 

 

 Any suggestions?

12 REPLIES 12
bastostiago
Regular Visitor

Hi @stribor45, generally, when I use a REST API to get data, I employ a Dataflow in Power BI Service, and then connect my report to this dataflow.

 

With this setup, I encounter an issue because I have to schedule both the dataflow and the dataset. To resolve this, I use Power Automate to trigger the dataset refresh automatically once the dataflow finishes refreshing.

 

I hope this explanation is clear enough.

Do you have an example/tutorial about Dataflow set up with API? I am suprised because all of these tutorials suggest using RelativePath and Query parametars of the WebContents function yet I am not able to make it work with simple example so I am wondering if I missing something simple or these cant be done currently any more

stribor45
Post Prodigy
Post Prodigy

I tried without question mark as well and that didn't work. It is an offset

 

stribor45_0-1714612024101.png

 

@lbendlin my problem is actually more complicated but the idea is the same so thats why i posted this simple example which should be straight forward but doesnt seem to have ability to be refreshed in Service

lbendlin
Super User
Super User

Remove the question mark from RelativePath

 

is the query parameter called start or offset?

is this something that cant be solved by power query? I have tried removing pieces of the URL and adding it to relative path in hope that it would work to no luck. anything else i can try?

Show what you have tried, and what error message you got.

let
    headers = [#"Content-Type" = "application/json", #"Accept"="application/json"],
    getJson = (url) => 
      let
          Source = Json.Document(Web.Contents(url, [RelativePath = "api/v2/pokemon", 
                                                    Query=[limit="100", offset="0"], Headers = headers]))
      
      in 
        Source,
    
    data = getJson("https://pokeapi.co")
in
    data

I dont have an error per say but what I do get is error in service that this cant be refreshed.

 

stribor45_0-1715255372255.png

 

 

 

Is 

https://pokeapi.co

a valid URL that returns a http 200?

yes 

stribor45_0-1715256600703.png

 

Is that the only base URL you are trying to access, or are there others?  If yes, how many?

 

(You should consider "showing" the base URL to the formula firewall monster, instead of trying to hide it)

not sure what you mean about firewall but if you mean to not pass the url as a parameter I tried that as well. No other URL's this is the whole code now and doesn't refresh in service.

 

let
    headers = [#"Content-Type" = "application/json", #"Accept"="application/json"],
    Source = Json.Document(
        Web.Contents("https://pokeapi.co", [RelativePath = "api/v2/pokemon", 
                                            Query=[limit="100", offset="0"], 
                                            Headers = headers]
                    )
    )             
in
    Source

 

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors