brad
January 19, 2023, 10:23pm
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 - (Read ContactList as stream )
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?
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
January 22, 2023, 11:05pm
3
Cheers - using a string value does not seem work for 'issueRedirect' or 'redirectToAuth'.
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
Closed
February 24, 2023, 5:15pm
5
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.