Just wondering if anyone has come across this problem before or can share any insight with me.
I have a shortcut that does this just fine:
make an API call, it’s a GET call
use the “Show Result” action to check I got something back
save the contents of the URL - which are a JSON dictionary - as response
then I get the dictionary from response and loop through it
But if I miss out Step 2, which is only there for debugging purposes, then the shortcut just seems to give up and not loop through the dictionary made from response.
Stuff I have tried:
The API is kind of slow to respond (like 2 seconds or so maybe) so I’ve tried making the shortcut wait instead of showing the response, for various lengths of time. Nothing worked.
Tried showing the result in the loop through the dictionary. Nothing happens, I don’t think it ever gets the dictionary from the response to get into the repeat with each item loop.
Tried moving the “Show response” to the very end of the shortcut. That does show the response, so it did get it, but the loop doesn’t get looped around all the same.
Tried it on iOS and macOS, same thing happens on both.
Tried putting a “Nothing” block in instead of the “Show response”, not helping either.
I don’t want to share the whole shortcut because you’d need an API key to get it to work but this is the relevant bit. If I remove the highlighted “Show response” block then the “repeat with each item in Dictionary” bit doesn’t fire.
It is of course hard to investigate without access, but what happens if you don’t set the response variable, but instead access directly via a magic variable? Same failing?
It’s frustrating! I’m going to have a look later and see if I can mock something up that does the same kind of thing without the API access being needed, see if I get the same behaviour elsewhere.
I just tried putting in a Text block instead of the Show Result block and that seems to make everything work ok, and isn’t interactive which is what’s needed. I wonder what those blocks are doing to my variable though! I feel like it might be trimming white space or changing line break formats or something like that but haven’t got time to look at it further at the moment.