Airtable API POST request fails with parameter validation error

I’m having trouble adding a new record to my Airtable base using Python. Every time I try to send data, I get a validation error.

Here’s what I’m working with:

import requests

# API endpoint setup
base_url = "https://api.airtable.com/v0/appXYZ123/MyTable?api_key=SECRET_KEY"

# Record data
record_info = {
    'fields': {
        'Title': 'Sample Entry'
    }
}

# Making the POST request
response = requests.post(url=base_url, data=record_info)

# Check response
print(response.text)

When I execute this code, I keep getting this error message:

{"error":{"type":"INVALID_REQUEST_UNKNOWN","message":"Invalid request: parameter validation failed. Check your request data."}}

I’ve double-checked my API key and base ID multiple times. The table exists and I have write permissions. What could be causing this parameter validation to fail? Any help would be appreciated!

u might be sending data instead of json in ur POST request. Airtable expects JSON format. Change it to requests.post(url=base_url, json=record_info) or add 'Content-Type': 'application/json' in headers, and wrap data with json.dumps().