I have a script that makes a request to a GIS API and fetches the response. When the script is in an app, it works at expected. As an automation, it does not work. The fetch returns a response with 403 status. This is strange because this means access is forbidden, however it was not forbidden when this script was an app.
I know there are differences between fetch() in apps vs automations, but from the documentation it seems like I can use fetch() like this. Is my geocode_data incorrectly formatted? In the app version, I use a FormData object for geocode_data, but I know that is not supported in automations. I referenced this page Airtable Scripting, which is a little unclear so I’m looking for more help!
Welcome to the community, @Erin_Ettenger! :grinning_face_with_big_eyes: I’ve never used new Request to build a request before calling an API using fetch. I just call fetch directly. Not sure if that’s part of the problem or not. Also, I noticed that you’re directly passing your data object instead of converting it to a JSON string first using JSON.stringify() and specifying the JSON content in a header property, which may also be an issue. Why the Scripting app let these slide and an automation scripting action doesn’t is a mystery.
Try this alternate version with these changes applied.
Thanks so much, Justin! I implemented your suggestions - they make sense to me. I think they got me closer to the solution, but I am still unfortunately getting this 403 error. I wonder if there are different permissions parameters for running an Automation vs an app?
The only difference that I know for certain is that scripts in the Scripting app run on your local system, whereas scripts in automations run on Airtable’s servers. It’s possible that this difference is somehow tied to the error. I recommend reaching out to Airtable support directly (in the app: Help → Contact support) to see if they can shed more light on the problem.