Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
I have a Power Query where the final result web service query needs to be called using the result of another web service.
The first call is necessary to generate what's called a JobId. This JobId is then used to pull data.
I'm getting the JobId successfully but when I try to run the final query I get a Bad Request error. The reason for the error is the job is not completed. These requests typically take less than a second or two.
Seems like the simple solution would be to delay running the final query so I've tried to run it with Function.InvokeAfter. It sill fails.
Could the issue be that the root url for both is the same?
Here's the syntax I'm using.
let
body = "{""getMyStuff"":true,""}",
data =Web.Contents("MyUrl",[Content=Text.ToBinary(body),Headers=[#"apikey"="mykey"]]),
DataRecord = Json.Document(data),
testJobId=DataRecord[jobId],
getAPI = ()=> Csv.Document(Web.Contents("MyUrl/getjob/"&testJobId&"/results", [Headers=[apikey="mykey"]]),[Delimiter=",", Columns=12, Encoding=65001, QuoteStyle=QuoteStyle.None]),
Source = Function.InvokeAfter(getAPI, #duration(0,0,0,30)),
in
Source
Any help is greatly appreciated.
You likely need to hand "testJobId" over to "getAPI" as a parameter, or specify the scope.
Thanks for the response. Unfortunately I've tried setting testJobId as a parameter but I get the following.
Formula.Firewall: Query 'JobId Forecast EDA' (step 'Filtered Rows') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination.
You didn't mention that you need this to work in the service. There are multiple articles that describe how to defeat the formula firewall dragon - pick the approach you like best. Read about Power Query partitions.