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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
nojust1
Frequent Visitor

Calling web service with result from another web service

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.

3 REPLIES 3
lbendlin
Super User
Super User

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.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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