APIs & Integrations

Gonzalo
Colaborador líder | Partner nivel Diamond
Colaborador líder | Partner nivel 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.

Thank you,


Gonzalo Torreras

HubSpot freelance developer

hola@gonzalotorreras.com
www.gonzalotorreras.com
Schedule a meeting
1 Respuesta 1
Jaycee_Lewis
Administrador de la comunidad
Administrador de la comunidad

Importing two CSV - importFileConfig

Hi, @Gonzalo 👋 Thanks for posting a great question. Let's see if we can get our community involved.

 

Hey, @Jake_Lett @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

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Me gusta