Bulk Import CRM Data help

Hey @JakeBreaksStuff,

A couple of things here that jumps out to me:

1. The excel file consists of 7 columns in which only 5 column was mapped. Namely: website url, firstname, ad ge, mobile phone number and city.

2. The filename key value should match with the file csv file name

As such, what I did was:

1. Removed the create date and stock photo column on the TestData.csv excel sheet:

2. Modified the code to match “fileName”: “TestData.csv”

import requests
import json

url = "https://api.hubapi.com/crm/v3/imports?hapikey={{hapikey}}"

data = {
 "name": "test_import",
 "files": [
 {
 "fileName": "TestData.csv",
 "fileFormat": "CSV",
 "fileImportPage": {
 "hasHeader": True,
 "columnMappings": [
 {
 "ignored": False,
 "columnName": "FirstName",
 "idColumnType": None,
 "propertyName": "firstname",
 "foreignKeyType": None,
 "columnObjectType": "CONTACT",
 "associationIdentifierColumn": False
 },
 {
 "ignored": False,
 "columnName": "Web Site URL",
 "idColumnType": None,
 "propertyName": "website",
 "foreignKeyType": None,
 "columnObjectType": "CONTACT",
 "associationIdentifiedColumn": False
 },
 {
 "ignored": False,
 "columnName": "Ad_Age",
 "idColumnType": None,
 "propertyName": "ad_age",
 "foreignKeyType": None,
 "columnObjectType": "CONTACT",
 "associationIdentifiedColumn": False
 },
 {
 "ignored": False,
 "columnName": "City",
 "idColumnType": None,
 "propertyName": "city",
 "foreignKeyType": None,
 "columnObjectType": "CONTACT",
 "associationIdentifiedColumn": False
 },
 {
 "ignored": False,
 "columnName": "Mobile Phone Number",
 "idColumnType": None,
 "propertyName": "mobilephone",
 "foreignKeyType": None,
 "columnObjectType": "CONTACT",
 "associationIdentifiedColumn": False
 }
		]
	}
}
]}

datastring = json.dumps(data)

payload = {"importRequest": datastring}

files = [
 ('files', open('/Users/wgoh/Documents/TestData.csv','rb'))
]

response = requests.request("POST", url, data = payload, files = files)

print(response.text.encode('utf8'))
print(response.status_code)

and it works. Could you try and see if it works for you?

Also, I copied the full file path of the csv file.