Issue Downloading Contact List Contacts

I'm currently using the Javascript SDK in a React App. I need to display the list of contacts from a Contact List in a table.

I'm using loginImplicitGrant with OAuth to login, and pagekite service to get a public URL locally on my dev environment. I can successfully make several API calls but when I try to call outboundApi.getOutboundContactlistExport I get a CORS error. This is the code I'm using and I'm attaching the error message from the Chrome console as an image <the code below is called after executing outboundApi.postOutboundContactlistExport(contactListId)>:

const GetContactListContent = (platformClient, outboundApi, contactListId) => {
    let opts = { 
        'download': "false" // String | Redirect to download uri
    };

    outboundApi.getOutboundContactlistExport(contactListId, opts)
    .then((data) => {
        // console.log(`getOutboundContactlistExport success! data: ${JSON.stringify(data, null, 2)}`);
        const client = platformClient.ApiClient.instance;
        var downloadUri = data.uri;
        return request({
            uri: downloadUri,
            qs: { issueRedirect: 'false' },
            headers: {
                'authorization': `bearer ${client.authData.accessToken}`,
                Accept: 'application/json',
                'Content-Type': 'application/json'
            }
        });
    })
    .then((res) => {
        // Show downloaded file in console
        var resObject = JSON.parse(res);            // Contains the AWS URL
        console.log(resObject);
        return request({
            uri: resObject.url
        });
        // setLoaded(true);
    })
    .then((res) => {
        // Show downloaded file in console
        console.log(res);
        setLoaded(true);
    })
    .catch((err) => {
        if (err.body && err.body.code === 'no.available.list.export.uri')
            // Wait until file is available for download and try downloading again.
            // For some reason the file isn't available right away. Wait 1 second and try download again
            setTimeout(
                function() {
                    GetContactListContent(platformClient, outboundApi, contactListId)
                }, 1000
            );
        else {
            console.log('There was a failure calling getOutboundContactlistExport');
            console.error(err);
        }
    });
}

CORS_Error

BTW, Is there an easier way to get the list of contacts from a Contact List in JSON Format?

I don't believe CORS is enabled for contact list exports. However, it seems like this should be a valid use case. Please open a case with PureCloud care to prioritize the inquiry into this potential issue. Care may determine that this is working as intended, in which case you can request that CORS be enabled and share your use case at https://purecloud.ideas.aha.io/ideas.

No, exporting the list is the only way.

Copy that. Hopefully we can get this resolved as quick as posible. We have limited time to deliver this project to the client.

Thank you Tim!

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