Distribute provided input from a repeat action into a Get request

Hello,

I’m trying to distribute the prompted input in a shortcut into a dictionary field in a Get Contents of URL action and can’t figure it out. I’m using the Tally app and the Airtable API.

I use Tally to choose which set of prompts to present. All prompts are help in a dictionary [Day 1: question 1, question 2, questions 3; Day 2: questions 1 questions 2, question 3]

I repeat with each of the values taken for the day and ask for input.

Then I have the Airtable API URL and the Get Contents of URL action set for POST. In the Request Body section of the Get Contents of URL actions I have a dictionary called fields but I can’t get the previous chose values to distribute into the correct fields or the repeated prompt inputs into the values either.

I’m sure I made a mess of explaining my question, hoping someone gets this!

Thanks!

P.S. The API works fine for me to post to a database when I manually type in the data. The main problem I have is I can’t seem to assign provided input 1, provided input 2, etc into the right fields of the Get Contents of Url action

It sounds like you just want to insert a (magic) variable into a field. Do you know about magic variables?

If you do, then I’m guessing it might be a use of repeats that’s requires. Possibly building your data prior to the ‘get’.

It’s a bit hard to “see” what’s going on without actually having the shortcut to see. Any chance you can share a sanitised (no API key, etc.) version of the shortcut, or at least some pertinent screenshots of how you capture and where you need the data?

Hi again Sylumer, thanks for the speedy response! I did try magic variables but each field filled with all provided input instead of each input distributed through each field. I’ll screenshot and send as soon as I can. I’m starting to suspect my approach is flawed and might need to adjust my use of the Airtable API

Here are screenshots. You can see the whole flow, and inside the dictionary:1 holding some prompts and inside the fields dictionary in the PATCH request




Okay. I think I follow the gist of it.

Here’s a genericised one based along the same lines that I think should illustrate a way it could be done.

https://www.icloud.com/shortcuts/0f9d0bddfd1643ef93810ba6784048f4

When it gets to the AirTable bit it purposefully fails (for obvious reasons), but look at the data and I’ve commented it throughout in an attempt to explain what is going on.

Hope that helps.

1 Like

Okay I can this that this would definitely work but I’m struggling to understand the looping section. Is that Ask For Input > Set Dictionary Value > Set Variable? And then in the PATCH selecting that variable and choosing a specific value? That last bit I had no idea existed, so that’s great! But I don’t really understand how the loop is building the dictionary.

I did brute-force a solution earlier this morning but it required call the API 7-8 times in the shortcut which makes it really slow

The loop gets a value, updates a dictionary and sets the variable to the updated dictionary so that it is ready for the next iteration or loop end.

Ah, I see now. I implemented the loop you created and it works perfectly. And it’s much faster than hitting the API for each individual field for each added record. Now it only hits it once.

Thanks again sylumer!!