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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
scott_hsd
Frequent Visitor

Error dynamic data source, cant save dataflow using value.waitfor

Hi I am using the value.waitfor in a function with an API, I am pretty sure the parameters to this function within the web.contents is causing the issue, however, I am not sure how I can restructure this to get around this, any suggestions would be great, thanks

 

// Practitest_ProjectTests
let
    Source = (ProjectKey as text) => let
        Practitest_ProjectIssues = let
        Source = ValueWaitfor(
            (iteration) =>
                let
                    result = Web.Contents("https://api.practitest.com/api/v2/", [RelativePath= "projects/" & ProjectKey & "/tests.json?api_token=" & Practitest_api_token] & [ManualStatusHandling = {429}, IsRetry = iteration > 0]),
                    status = Value.Metadata(result)[Response.Status],
                    actualResult = if status = 429 then null else result
                in
                    actualResult,
            (iteration) => #duration(000, Number.Power(2, iteration)),
            10)
    in
        if Source = null then
            error "ValueWaitfor() Failed after multiple retry attempts"
        else
            Source,
        #"Imported JSON" = Json.Document(Practitest_ProjectIssues,65001),
        data = #"Imported JSON"[data],
        #"Converted to Table" = Table.FromList(data, Splitter.SplitByNothing(), nullnull, ExtraValues.Error),
        #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id""type""attributes"}, {"id""type""attributes"}),
        #"Expanded attributes" = Table.ExpandRecordColumn(#"Expanded Column1", "attributes", {"project-id""display-id""name""description""preconditions""steps-count""status""run-status""last-run""author-id""assigned-to-id""assigned-to-type""cloned-from-id""planned-execution""version""priority""duration-estimate""custom-fields""automated-test-info""tags""folder-id""created-at""updated-at"}, {"project-id""display-id""name""description""preconditions""steps-count""status""run-status""last-run""author-id""assigned-to-id""assigned-to-type""cloned-from-id""planned-execution""version""priority""duration-estimate""custom-fields""automated-test-info""tags""folder-id""created-at""updated-at"}),
        #"Expanded automated-test-info" = Table.ExpandRecordColumn(#"Expanded attributes", "automated-test-info", {"automated-test-design""script-repository""num-of-results""suite-path""client-type""script-path""results-path""script-name"}, {"automated-test-design""script-repository""num-of-results""suite-path""client-type""script-path""results-path""script-name"})
    in
        #"Expanded automated-test-info"   
in
    Source
1 ACCEPTED SOLUTION
scott_hsd
Frequent Visitor

All found the issue, so instead of this

result = Web.Contents("https://api.practitest.com/api/v2/", [RelativePath= "projects/" & ProjectKey & "/tests.json?api_token=" & Practitest_api_token] & [ManualStatusHandling = {429}, IsRetry = iteration > 0]),

 

I used this

result = Web.Contents("https://api.practitest.com/api/v2/", [RelativePath= "projects/" & ProjectKey & "/tests.json?api_token=" & Practitest_api_token, ManualStatusHandling = {429}, IsRetry = iteration > 0]),

View solution in original post

3 REPLIES 3
scott_hsd
Frequent Visitor

All found the issue, so instead of this

result = Web.Contents("https://api.practitest.com/api/v2/", [RelativePath= "projects/" & ProjectKey & "/tests.json?api_token=" & Practitest_api_token] & [ManualStatusHandling = {429}, IsRetry = iteration > 0]),

 

I used this

result = Web.Contents("https://api.practitest.com/api/v2/", [RelativePath= "projects/" & ProjectKey & "/tests.json?api_token=" & Practitest_api_token, ManualStatusHandling = {429}, IsRetry = iteration > 0]),

scott_hsd
Frequent Visitor

Thanks, I read through that, not quite sure how to disect this though

 

result = Web.Contents("https://api.practitest.com/api/v2/", [RelativePath= "projects/" & ProjectKey & "/tests.json?api_token=" & Practitest_api_token] & [ManualStatusHandling = {429}, IsRetry = iteration > 0]),

jennratten
Super User
Super User

I believe you will need to combine the various elements to create your relative path prior to passing it into the Web.Contents function. This can be done by creating the relative path in table rows and then invoking the function for the table column.

Here is a good resource:

https://hatfullofdata.blog/power-query-dynamic-data-source-and-web-contents/ 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors
Top Kudoed Authors