Legacy Dev Forum Posts

 View Only

Sign Up

Error umpload contact list

  • 1.  Error umpload contact list

    Posted 06-05-2025 18:03

    Fabian_Quiroga | 2021-12-31 18:22:16 UTC | #1

    hi, I am uploading a .cvs file to a contact list through NODE at the time of doing it generates this error

    require('dotenv').config(); const axios = require('axios'); const fs = require('fs');

    conten = { 'id': "a74f5613-c7a3-4747-b89f-5e934a5dea50", 'file': fs.readFileSync('./Contact List.csv'), 'fileType': "contactlist", 'contact-id-name': 'Cedula' } axios.post("https://apps.mypurecloud.com/uploads/v2/contactlist", conten, { headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', 'Authorization': bearer ${process.env.GENESYS_TOKEN} } }).then(res => { console.log(res.data); }).catch(error => { if (error.response) { console.error(error.response.status); console.error(error.response); } })

    error 400


    anon11147534 | 2022-01-04 08:29:03 UTC | #2

    Hi,

    It's hard to know exactly what the issue is without a response body. It's possible that your Content-Type and Accept headers are not necessary and are causing the issue. You can use the Uploading Contacts to a Contact List Javascript tutorial as a reference to show how this is achieved in Javascript.


    Jerome.Saint-Marc | 2022-01-04 08:41:18 UTC | #3

    Hello,

    The request's content-type must be "multipart/form-data" and the body must be encoded accordingly (i.e. FormData). The link Ronan has mentioned above is doing this with javascript/jquery. You should check how to do the equivalent with axios.

    Regards,


    Fabian_Quiroga | 2022-01-04 13:54:10 UTC | #4

    Hi,

    But in the example it is with a browser and I have to do it with node, don't you have an example with node?


    Jerome.Saint-Marc | 2022-01-04 14:18:03 UTC | #5

    Hello,

    We do not have a node example for the upload of contact list. But you can possibly check this web page that describes how to use Axios with Multipart Form Data.

    Regards,


    Fabian_Quiroga | 2022-01-18 20:00:18 UTC | #6

    Hello, this was the way I do it

    const form = new FormData(); const token = await Token(); form.append('id', idlista); form.append('file[]', fs.createReadStream(csv)); form.append('fileType', 'contactlist'); form.append('contact-id-name', 'cedula'); let head = form.getHeaders(); head.Authorization = 'bearer ' + token; axios({ method: "post", url: "https://apps.mypurecloud.com/uploads/v2/contactlist", data: form, headers: head }).then(function (response) { console.log(response.data) }).catch(function (error) { console.log(error) });


    system | 2022-02-18 19:57:35 UTC | #7

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 13102