Legacy Dev Forum Posts

 View Only

Sign Up

DownloadsApi not appending queryString correctly

  • 1.  DownloadsApi not appending queryString correctly

    Posted 06-05-2025 18:03

    brad | 2023-01-19 22:24:07 UTC | #1

    Hi Everyone,

    I'm trying to get the download Uri for a Contact list export which I have created using the OutboundApi. However, I'm getting a CORS error because it looks like the DownloadsApi.download function is not formatting my request with the options I pass in. I have followed the solution proposed by @tim.smith here - (https://developer.genesys.cloud/forum/t/read-contactlist-as-stream/1220)

    My code is as follows:

    ` const opts = { contentDisposition: '', issueRedirect: false, redirectToAuth: false } DownloadsApi.getDownload(this.downloadId, opts) .then((getDownloadResponse) => { console.log(getDownloadResponse ->\n\r${JSON.stringify(getDownloadResponse)}) })`

    It returns the CORS error I believe because the 'issueRedirect: false' option is not appended to the request. The request which gets sent is as follows: https://api.mypurecloud.com.au/api/v2/downloads/?contentDisposition=&issueRedirect=&redirectToAuth= instead of what I expected https://api.mypurecloud.com.au/api/v2/downloads/?contentDisposition=&issueRedirect=false&redirectToAuth=false

    Anyone got ideas?


    tim.smith | 2023-01-19 22:42:28 UTC | #2

    I've asked the SDK team to take a look at it not sending false as a value. Can you try using a string value instead to see if that works around the issue? i.e. issueRedirect: "false"


    brad | 2023-01-22 23:05:08 UTC | #3

    Cheers - using a string value does not seem work for 'issueRedirect' or 'redirectToAuth'.


    charlie.conneely | 2023-01-24 17:14:33 UTC | #4

    Hi Brad,

    I wasn't able to recreate your issue with our latest JS SDK version 157.0.0

    I attached below my code that worked fine. If you cannot find any differences which are causing your problem, please let me know.

    const platformClient = require('purecloud-platform-client-v2');
    
    const client = platformClient.ApiClient.instance;   
    
    let clientId = "<client ID>"
    let clientSecret = "<client secret>"
    client.setEnvironment(platformClient.PureCloudRegionHosts.us_east_1);
    
    client.loginClientCredentialsGrant(clientId,clientSecret)
    .then(()=> {
        let apiInstance = new platformClient.DownloadsApi();
        let downloadId = "a123456b1234c123"; 
        const opts = { contentDisposition: '', issueRedirect: false, redirectToAuth: false }
    
        apiInstance.getDownload(downloadId, opts)
        .then((data) => {
            console.log(`getDownload success! data: ${JSON.stringify(data, null, 2)}`);
        })
        .catch((err) => {
            console.log("There was a failure calling getDownload");
            console.error(err);
        });
    
    })
    .catch((err) => {
        console.log(err);
    });

    system | 2023-02-24 17:15:26 UTC | #5

    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: 18065