I have written the following Python script, but I’m encountering an issue where certain cells cannot be retrieved, resulting in a not found error. Interestingly, when I attempt to fetch all fields, it works seamlessly. I’m using a URL parameter for this request. Below is the code I’m using:
from flask import Flask, render_template, request
import requests
app = Flask(__name__)
@app.route('/')
def loading():
return render_template('loading.html')
@app.route('/result')
def result():
submission_identifier = request.args.get('submission_id')
airtable_endpoint = f"https://api.airtable.com/v0/apptIx6sSgAbZaIV8/fundfox/{submission_identifier}"
headers = {
"Authorization": "Bearer XXXXXXXXX"
}
response = requests.get(airtable_endpoint, headers=headers)
response_data = response.json()
specific_field_content = response_data.get('fields', {}).get('submission_id', 'No results found')
print("Submission ID:", submission_identifier)
print("Airtable Response:", response_data)
print("Response Status Code:", response.status_code)
return render_template('result.html', specific_field=specific_field_content)
if __name__ == '__main__':
app.run(debug=True)
When I modify the script to obtain all fields, I successfully receive a response. Here is the modified part of the code:
response = requests.get(airtable_endpoint, headers=headers)
response_data = response.json()
# Retrieve all fields
fields = response_data.get('fields', {})
I also included a visual reference for the Airtable layout. What am I overlooking in this process?
- I have changed the row format for the
submission_idin Airtable. - I have modified the code several times.