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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
shuhn1229
Resolver I
Resolver I

POST Request with REST API

Hi all,

 

I am working with a REST API that sends in POST. I am using the code below, and I am able to refresh in desktop client after about 20 minutes. However, when I perform schedule refresh I get the following error: "The underlying connection was closed: The connection was closed unexpectedly". It seems like the cloud client is "giving up too easily". I am using a datagateway.

 

 

let
    Source = let
    Source = let
 url = "https://url.com",
    body = "{""id"": ""XXX""               }",
    Source = Json.Document(Web.Contents(url, [Timeout= #duration(0, 1, 0, 0),
        Headers = [#"Authorization"="Basic XXXX", #"Content-Type"="application/json", #"Connection" = "keep-alive"],
        Content = Text.ToBinary(body)
    ]))

 

 

The API has a lag before data is sent back for large queries. I am wondering if there is a way to keep the connection open in my mQuery code. I already tried adjusting the timeout with no luck.

2 REPLIES 2

I resolved this by pre-caching the query. It has something to do with the fact that if the cloud refresh isn't recieving a response, it will kill the connection after about 6 minutes (time out does not solve this). Meanwhile, if the query is preloaded, even if its large, cloud refresh works. I took a look at those sources, I didn't see anything applicable but I do appreicate your help. I'm leaving this open in case anyone ever solves it.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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