I’m trying to bulk upload contact information to HubSpot using their CRM imports endpoint but keep getting a 415 status code error. My contact data includes fields like last name, email, phone, state, and company website. I’ve 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": "LastName",
"idColumnType": None,
"propertyName": "lastname",
"foreignKeyType": None,
"columnObjectType": "CONTACT",
"associationIdentifiedColumn": False
},
{
"ignored": False,
"columnName": "Email Address",
"idColumnType": None,
"propertyName": "email",
"foreignKeyType": None,
"columnObjectType": "CONTACT",
"associationIdentifiedColumn": False
},
{
"ignored": False,
"columnName": "Phone_Number",
"idColumnType": None,
"propertyName": "phone",
"foreignKeyType": None,
"columnObjectType": "CONTACT",
"associationIdentifiedColumn": False
},
{
"ignored": False,
"columnName": "State",
"idColumnType": None,
"propertyName": "state",
"foreignKeyType": None,
"columnObjectType": "CONTACT",
"associationIdentifiedColumn": False
},
{
"ignored": False,
"columnName": "Company Website",
"idColumnType": None,
"propertyName": "company",
"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 requests. I’ve double checked that my CSV column headers match the property names in HubSpot. The 415 error suggests there might be an issue with the content type or request format but I’m not sure what I’m missing. Has anyone successfully used this API endpoint before?