La fonction de suggestion automatique permet d'affiner rapidement votre recherche en suggérant des correspondances possibles au fur et à mesure de la frappe.
Contributeur de premier rang | Partenaire solutions Diamond
Importing two CSV - importFileConfig
Hello!
I am trying to do an import with two CSVs and nodeJS HubSpotClient.
The provided example on the repo seems to be missing how to handle it, and I can't find useful information in the API documentation either (or I am missing how to translate it to it within the library).
My main question is how to define the importFileConfig.
This is what I have so far:
const importRequest = {
name: `CSVs: ${ file1.name } and ${ file2.name }`,
files: [
{
fileName: file1.name,
fileFormat: 'CSV',
fileImportPage: {
hasHeader: true,
columnMappings: file1.columnMapping
}
},
{
fileName: file2.name,
fileFormat: 'CSV',
fileImportPage: {
hasHeader: true,
columnMappings: file2.columnMapping
}
}
]
};
// what to do here? how can I send both files? is it possible to use this wrapper?
const importFileConfig = {
name: importRequest.name,
data: fs.readFileSync(file1.data, "utf8"),
options: {
filename: file1.name,
contentType: 'text/csv',
},
}
try {
const result = await hubspotClient.crm.imports.coreApi.create(importFileConfig, JSON.stringify(importRequest));
[...]
Any help would be really appreciated!
If this answer helps you to solve your questions please mark it as a solution.