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.