Forum Discussion
Anonymous
7 years agoNot applicable
Delay web query until condition met from another web query
I use an API that provides a Json response which includes a statusUrl and a downloadUrl. If I immediately hit up the downloadUrl there is usually no data. The statusUrl Json response advises when t...
- 7 years ago
Hi Anonymous,
I've prepared a template which you can use for solving your problem.
You have to add your logic for processing JSON responses and modify the WaitForList according your needs.
let // request data RequestDataRecord = fnProcessJson(Web.Contents("request data URL")), // wait 10x for 5 seconds WaitForList = List.Repeat({5}, 10),
// wait until the response is COMPLETE, but max 50 secs WaitForStatus = List.MatchesAny( WaitForList, each Function.InvokeAfter( () => fnProcessJson(Web.Contents("http://StatusCheckURL")), #duration(0,0,0,_) ) = "COMPLETE" ), // download file if WaitForStatus was successful DownloadFile = if WaitForStatus then fnProcessJson(Web.Contents("download data URL")) else null in DownloadFile
Nolock
7 years agoResident Rockstar
Hi Anonymous,
I've prepared a template which you can use for solving your problem.
You have to add your logic for processing JSON responses and modify the WaitForList according your needs.
let
// request data
RequestDataRecord = fnProcessJson(Web.Contents("request data URL")),
// wait 10x for 5 seconds
WaitForList = List.Repeat({5}, 10),
// wait until the response is COMPLETE, but max 50 secs
WaitForStatus = List.MatchesAny(
WaitForList,
each
Function.InvokeAfter(
() => fnProcessJson(Web.Contents("http://StatusCheckURL")),
#duration(0,0,0,_)
) = "COMPLETE"
),
// download file if WaitForStatus was successful
DownloadFile =
if WaitForStatus then
fnProcessJson(Web.Contents("download data URL"))
else
null
in
DownloadFileayangain17
2 years agoNew Member
Now it doesn't seem to work is there any workaround? the response is not getting updated so null is being returned always, but in postman the response gets completed within few seconds