Forum Discussion

stribor45's avatar
stribor45
Post Prodigy
2 years ago

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

  • Remove the question mark from RelativePath

     

    is the query parameter called start or offset?

    • stribor45's avatar
      stribor45
      Post Prodigy

      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?

      • lbendlin's avatar
        lbendlin
        Super User

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

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

     

     

    • stribor45's avatar
      stribor45
      Post Prodigy

      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

  • bastostiago's avatar
    bastostiago
    Frequent 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.

    • stribor45's avatar
      stribor45
      Post Prodigy

      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