Hey everyone! I’m stuck trying to make an API call from Airtable’s script editor. The GET request needs an Authorization header with a base64 encoded string of api: USERNAME:YOUR_API_KEY.
The problem is, btoa() isn’t available in Airtable. I found a workaround online, but it’s not working:
I’m still getting 401 UNAUTHORIZED errors. I even tried encoding the string on my computer with btoa() and pasting the result, but no luck.
Any ideas on how to properly encode to base64 in Airtable’s editor? I’m out of ideas and really need to get this API connection working. Thanks for any help!
I’ve faced this issue before in Airtable’s script editor. While the Buffer solution is popular, I found a more reliable method using the built-in ‘base64’ module. Here’s what worked for me:
This approach is straightforward and doesn’t require external libraries. Make sure you’re using the correct API endpoint and that your API key has the necessary permissions. If you’re still getting 401 errors, it might be worth checking with the API provider to ensure there aren’t any additional authentication steps required. Also, double-check that you’re formatting the Authorization header correctly in your fetch request.
I’ve encountered similar issues with base64 encoding in Airtable’s script editor. One reliable method I’ve found is using the ‘crypto’ module, which is available in Airtable’s environment. Here’s a snippet that should work for you:
This approach uses SHA-256 hashing, which is more secure than standard base64 encoding. It’s worth noting that some APIs might expect a specific encoding method, so double-check their documentation. Also, ensure your API key is up-to-date and has the necessary permissions. If you’re still getting 401 errors after this, the issue might be on the API provider’s end or with how the Authorization header is being constructed in your request.