Good morning all,
I have built and used a shortcut that accesses an Airtable base via the API, then returns a dictionary that I can process to filter for just the exact email addresses I specified, then sends the final list to Airmail via an x-callback URL.
I’d like to bring the data from Airtable to an iCloud JSON document so I can more easily use it when I’m not online. I fly a lot, and it would help keep me working while in the air. I also use a MBP, which could keep the iCloud version so I can use it there without tethering.
So - I wrote a shortcut to try and bring the Airtable information down and save it to the JSON file. (Thinking I could trigger this from a Pushcut or something to do it when I’m online.) I’ve run into multiple issues.
1 - Using Save File - I get an error when I assign a file name. Either - that file doesn’t exist, or that file already exists (even with overwrite checked). The only way I can get it to work is to ensure the shortcut creates the file, then it seems like it is willing to overwrite it. Is there a reliable way to get this step to create the file with a specific file name? Seems hit-and-miss. The only reliable way is to stick with the default file name of “Dictionary.json.”
2 - I have a subroutine that returns a dictionary containing all of my data (using Show Result I can verify the return contains it all.) Airtable includes the key value pairs inside a wrapper key “fields”.
If I simply put a Save File (accepting the returned dictionary) step next, it only saves the last record.
If I put a Save File (as Dictionary - Get value for key “fields”) step next it only saves the first record.
If I use a text step to convert the dictionary to text, and save the text file, I get the error “Cannot convert from text to dictionary” when I use a Get File step and try to put it back in a dictionary. (Note - in this case - all records are present, but the appended filename suffix is .txt.)
I jut don’t get it. I have a dictionary, and I can work with it fine, I just don’t seem to be able to save it as JSON. Does anyone have a reference where I can read more detailed documentation? Or can you point me in a direction to understand how the Save File step is interpreting the dictionary?
One other note - I used Jayson to look at the results each time. The first two produce valid JSON, but only 1 record. One thing I truly don’t understand it why the first scenario results in the last record. (I don’t extract it from the wrapper key “fields”, so how does it only grab the last key-value pair inside the “fields” dictionary?” ) Also - Jayson can’t read the text file - so I’m just visually inspecting that one.
Thanks for any help or ideas. I’m sorry I can’t share the shortcut (confidential data and all.)
(Probably goes without saying, but I’m not a developer of any kind.)