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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! 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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.

Top Solution Authors