Jul 14, 2022 6:13 AM
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.
Thank you,
|
Jul 14, 2022 6:57 PM
Hi, @Gonzalo 👋 Thanks for posting a great question. Let's see if we can get our community involved.
Hey, @BootstrapC @Teun @LMeert @lindahl @Bryantworks, have you done this using node.js? Or do you have any thoughts on how our friend @Gonzalo might approach this challenge?
Thank you very much! — Jaycee