I am a beginner seeking assistance with adding a new record to my Airtable database utilizing Python 3. The documentation provides the following curl commands:
$ curl -v -XPOST https://api.airtable.com/v0/restoftheurl \
-H "Authorization: Bearer My_API_Key" \
-H "Content-type: application/json" \
-d '{
"fields": {
"Item": "Headphone",
"Quantity": "1",
"Customer_ID": [
"My_API_Key"
]
}
}'
The Python code I attempted is:
import requests
api_endpoint = "https://api.airtable.com/v0/restoftheurl"
payload = {
"Authorization": "Bearer My_API_Key",
"Content-Type": "application/json",
"fields": {
"Item": "randomitem",
"Quantity": "5",
"Customer_ID": ["randomrecord"]
}
}
response = requests.post(api_endpoint, json=payload)
print(response.json())
However, the resulting error is:
{'error': {'type': 'AUTHENTICATION_REQUIRED', 'message': 'Authentication required'}}
Could someone guide me on the correct way to authenticate this request or clarify what I may be doing incorrectly?