Hello everyone,
I’m encountering an error whenever I run custom code within callin.io's Code by Zapier. The goal is to generate a personalized “Welcome” message with a related custom “Link” embedded within this welcome text, intended for customers. The problem arises when I request the record with the “Link” from the Airtable Web API. The response status code is 200, which indicates success. The data and response are also correct when tested in Visual Studio Code.
HOWEVER, when I execute the code within callin.io's Code by Zapier, the mentioned “Link” is absent.
Has anyone else experienced a similar issue?
import requests
import json
input_data = {
'api_key':'',
'base_form':'theBaseWithTheTable',
'program':'theProgramName',
'client_name':'Customer',
'table_form':'theTableWithTheLink'
}
API_KEY = input_data['api_key']
base_id = ''
table_id = ''
client_name = input_data['client_name']
link = ''
url = f'https://api.airtable.com/v0/meta/bases'
headers = {
'Authorization': f'Bearer {API_KEY}',
'Content-Type':f'application/json',
}
# get base by program name
response = requests.get(url, headers=headers)
if response.status_code == 200:
data = response.json()
for base in data['bases']:
for k, v in base.items():
if input_data['base_form'] in v:
base_id = base.get('id')
url = f'https://api.airtable.com/v0/meta/bases/{base_id}/tables'
# get table by base
response = requests.get(url, headers=headers)
if response.status_code == 200:
data = response.json()
for table in data['tables']:
for k, v in table.items():
if input_data['table_form'] in v:
table_id = table.get('id')
url = f'https://api.airtable.com/v0/{base_id}/{table_id}'
# find the link into the table
response = requests.get(url, headers=headers)
if response.status_code == 200:
data = response.json()
for row in data['records']:
fields = row.get('fields')
for k, v in fields.items():
if input_data['program'] in v:
link = fields.get('Link')
welcome = f'<h1>¡Welcome {client_name}</h1> <p>Complete the following form:</p> <a href="{link}">Your Form</a> '
output = {{'welcome':welcome,'link':link}}
Hi
Good question.
Have you attempted to use Python logging to help you identify which Record IDs are being returned, to then confirm that those Airtable Record IDs have values for the Link field?
Have you tried using ChatGPT to assist with the Python Code?