I'm very new to Power Query and trying to piece a little demo together in Excel.
I have two web endpoints: I have to post some content to the first endpoint, this gives me the url of the second endpoint and then I have to query this second endpoint for the actual results. The second endpoint gives back a json response and in it, there is a field that represents if the results are ready or not. If the results are ready, they can be processed, if not, the endpoint should be queried again at a later date.
Here's the code I have so far:
let
apikey = "MYAPIKEY",
proxyendpoint = "URL OF THE FIRST ENDPOINT",
bytesbody = File.Contents("FILE TO POST"),
headers = [#"Ocp-Apim-Subscription-Key" = apikey],
bytesresp = Web.Contents(proxyendpoint, [Headers=headers, Content=bytesbody]),
jsonresp = Json.Document(bytesresp),
opLoc = jsonresp[OperationLocation],
getResult = (url) =>
let
linesBody = Web.Contents(url, [Headers=headers]),
linesJson = Json.Document(linesBody),
resultStatus = linesJson[status],
linesData = if (resultStatus = "Succeeded") then
linesJson[recognitionResult][lines]
else
Function.InvokeAfter(()=>@getResult(url),#duration(0,0,0,5))
in
linesData,
linesText = List.Transform(getResult(opLoc), each _[text]),
table = Table.FromList(linesText)
in
table
My problem is that when I check with Fiddler, I see the second endpoint queried once, I can check there in the response that the results are not ready, the data loading "hangs", but I cannot see any additional calls to the second endpoint, so basically my recursive calls are not being evaluated.
What am I doing wrong?