I’m trying to upload contact records to HubSpot using their import API but keep getting a 415 status code error. My contacts have basic info like name, age, phone, location, and website URL. I tested with both CSV and Excel formats but neither works.
import requests
import json
api_endpoint = 'http://api.hubapi.com/crm/v3/imports?hapikey=abc....xyz'
data_file = "contact_upload.csv"
request_headers = {'accept': 'application/json'}
payload = {
"name": "bulk_contact_import",
"files": [
{
"fileName": data_file,
"fileFormat": "CSV",
"fileImportPage": {
"hasHeader": True,
"columnMappings": [
{
"ignored": False,
"columnName": "Name",
"idColumnType": None,
"propertyName": "firstname",
"foreignKeyType": None,
"columnObjectType": "CONTACT",
"associationIdentifiedColumn": False
},
{
"ignored": False,
"columnName": "Website",
"idColumnType": None,
"propertyName": "website",
"foreignKeyType": None,
"columnObjectType": "CONTACT",
"associationIdentifiedColumn": False
},
{
"ignored": False,
"columnName": "Age",
"idColumnType": None,
"propertyName": "age_field",
"foreignKeyType": None,
"columnObjectType": "CONTACT",
"associationIdentifiedColumn": False
}
]
}
}
]
}
response = requests.post(url=api_endpoint, data=payload, headers=request_headers)
print(response.status_code)
print(response.text)
The file path is correct and my API key works for other calls. I double checked that my column names match what’s in HubSpot. No test data shows up in my account so the import is definitely failing. Has anyone dealt with this 415 error before? What am I missing in my request format?