CRM Imports Endpoint

Hi, can someone help me with the sample payload/body/data part for this POST request? (Accounts Dashboard | HubSpot)
Apparently we can use Excel or CSV source file but i couldn’t manage to define it

import requests

url = "https://api.hubapi.com/crm/v3/imports/"

querystring = {"hapikey":"xxxx-xxxx"}

payload = "{\"importRequest\":\"datetime\"}"
headers = {
 'accept': "application/json",
 'content-type': "multipart/form-data"
 }

response = requests.request("POST", url, data=payload, headers=headers, params=querystring)

print(response.text) 

Thanks

Hi, @etezisci.

Our documentation is still a work in progress, but the following worked for me:

var request = require('request');var fs = require('fs');var options = {'method': 'POST','url': 'https://api.hubapi.com/crm/v3/imports/?hapikey=xxxx-xxxx','headers': {'Content-Type': 'application/x-www-form-urlencoded'},formData: {'files': {'value': fs.createReadStream('/Users/itakushi/Documents/API_Import_1.csv'),'options': {'filename': 'API_Import_1.csv','contentType': null}},'importRequest': '{"name":"API_Import_1","files":[{"fileName":"API_Import_1.csv","fileImportPage":{"hasHeader":true,"columnMappings":[{"ignored":false,"columnName":"email","idColumnType":"HUBSPOT_ALTERNATE_ID","propertyName":"email","foreignKeyType":null,"columnObjectType":"CONTACT","associationIdentifierColumn":false},{"ignored":false,"columnName":"firstname","idColumnType":null,"propertyName":"firstname","foreignKeyType":null,"columnObjectType":"CONTACT","associationIdentifierColumn":false},{"ignored":false,"columnName":"lastname","idColumnType":null,"propertyName":"lastname","foreignKeyType":null,"columnObjectType":"CONTACT","associationIdentifierColumn":false}]}}]}'}};request(options, function (error, response) { if (error) throw new Error(error);console.log(response.body);});

Here’s a better look at the importRequest object:

{
 "name": "API_Import_1",
 "files": [
 {
 "fileName": "API_Import_1.csv",
 "fileImportPage": {
 "hasHeader": true,
 "columnMappings": [
 {
 "ignored": false,
 "columnName": "email",
 "idColumnType": "HUBSPOT_ALTERNATE_ID",
 "propertyName": "email",
 "foreignKeyType": null,
 "columnObjectType": "CONTACT",
 "associationIdentifierColumn": false
 },
 {
 "ignored": false,
 "columnName": "firstname",
 "idColumnType": null,
 "propertyName": "firstname",
 "foreignKeyType": null,
 "columnObjectType": "CONTACT",
 "associationIdentifierColumn": false
 },
 {
 "ignored": false,
 "columnName": "lastname",
 "idColumnType": null,
 "propertyName": "lastname",
 "foreignKeyType": null,
 "columnObjectType": "CONTACT",
 "associationIdentifierColumn": false
 }
 ]
 }
 }
 ]
}

My CSV file, API_Import_1.csv, had three columns. In order: “email” mapping to email, “firstname” mapping to firstname, and “lastname” mapping to lastname.

Here are screenshots of the draft documentation for the other fields:


Required Parameters

Optional Parameters

I hope this helps others while we work to publish formal documentation on this endpoint.

Thank you Isaac! It worked for me too.