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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Time Limit on API

Hi

I am very new to Power BI and trying to learn on the job

I have inherited some Power BI Queries that I need to update but the person who wrote them is no longer with the organisation, therefore I some help!!

I am getting data from an Assetic (Enterprise Asseet Management Software) database and bringing into Power BI

This the code I have:

let
// Assetic base URL
asseticUrl = "https://*************.assetic.net",

// Assetic advanced search profile GUID
asseticSearchGuid = "************",

// Assetic username
asseticUsername = "****************",

// Assetic authorisation token
asseticToken = "************",

// HTTP basic credentials Base-64 encoded

base64Auth = Binary.ToText(

Text.ToBinary(asseticUsername & ":" & asseticToken), BinaryEncoding.Base64

),

 

// HTTP Headers

httpHeaders = [

ContentType = "Application/JSON",

Authorization = "Basic " & base64Auth

],

 

// Export advanced search profile results (POST /api/v2/search/{id}/export)

asseticTaskId = Json.Document(

Web.Contents(

asseticUrl,

[

Headers = httpHeaders,

RelativePath = "api/v2/search/" & asseticSearchGuid & "/export",

Content = Json.FromValue("{}")

]

)

),

 


// Get status of the export (GET /api/v2/backgroundtask/{id})

getAsseticTask = () => Json.Document(

Web.Contents(

asseticUrl,

[

Headers = httpHeaders,

RelativePath = "api/v2/backgroundworker/" & asseticTaskId,

IsRetry = true

]

)

),

 

// Returns true if export task completes within 'n' x 'm' secs

asseticTaskComplete = List.MatchesAny(

List.Repeat({5}, 30), 

each Function.InvokeAfter(() => getAsseticTask(), #duration(0, 0, 0, _)

)[Status] = "Completed"

),

 

// Wait until export of results is complete

asseticTask = if asseticTaskComplete

then

getAsseticTask()

else

error ("Assetic export task failed to retrieve results"),

 

// Download document (GET /api/v2/document/{documentId}/file)

asseticFileCsv = Csv.Document(

Web.Contents(

asseticUrl,

[

Headers = httpHeaders,

RelativePath = "api/v2/document/" & asseticTask[DocumentId] & "/file"

]

)

),

 

// Promote the first row of values as column headers

Source = Table.PromoteHeaders(asseticFileCsv)

in

Source

 

The part of the code I am having issues with is in red font. I need to extend the time limit before the error message "Assetic export task failed to retrieve results" appears 

Any help is appreciated!

 

Thanks

GT

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

List.Repeat({5}, 30), 
each Function.InvokeAfter(() => getAsseticTask(), #duration(0, 0, 0, _)

It tries 30 times and waits five seconds between tries. I would up the seconds value a bit - do you really need to check every five seconds?

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thanks Ibendlin

I will try increasing the seconds value. Not sure why it was set at 5 seconds

Cheers

GT

lbendlin
Super User
Super User

List.Repeat({5}, 30), 
each Function.InvokeAfter(() => getAsseticTask(), #duration(0, 0, 0, _)

It tries 30 times and waits five seconds between tries. I would up the seconds value a bit - do you really need to check every five seconds?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.