In that case, the second screenshot is correct. You don’t add the file name to the end of the contentUri.
Now I am not sure about the error. Can you double check the access token you used in your postman is generated for the same user who exported the team messaging compliance and under the same account?
If you want to try this on Node JS code, install the RC JS SDK and provide your app and user credentials to run the code below.
const RingCentral = require('@ringcentral/sdk').SDK
const fs = require('fs')
const https = require('https');
const url = require('url')
RINGCENTRAL_CLIENTID = ""
RINGCENTRAL_CLIENTSECRET = ""
RINGCENTRAL_SERVER = 'https://platform.ringcentral.com'
RC_JWT_ADMIN =""
const rcsdk = new RingCentral({
server: RINGCENTRAL_SERVER,
clientId: RINGCENTRAL_CLIENTID,
clientSecret: RINGCENTRAL_CLIENTSECRET
})
var platform = rcsdk.platform();
rcsdk.login({ jwt: RC_JWT_ADMIN })
platform.on(platform.events.loginSuccess, async function(e){
console.log("Login success")
var contentUri = 'https://dl.mvp.ringcentral.com/file/XXXXXXXXX'
var u = url.parse(contentUri);
let domain = u.host
let path = u.pathname
let fileName = "test.jpg"
downloadFile(domain, path, fileName)
});
// DOWNLOAD FILE
async function downloadFile(domain, path, fileName){
var tokenObj = await platform.auth().data()
var accessToken = tokenObj.access_token
download(domain, path, accessToken, fileName, function(msg){
console.log(msg)
console.log("Save atttachment to the local machine.")
})
}
const download = function(domain, path, accessToken, dest, cb) {
var file = fs.createWriteStream(dest);
var options = {
host: domain,
path: path,
method: "GET",
headers: {
Authorization: `Bearer ${accessToken}`
}
}
const req = https.request(options, res => {
var chunks = [];
res.setEncoding('binary');
res.on('data', (chunk) => {
chunks += chunk;
}).on('end', () => {
file.write(chunks, 'binary');
file.on('finish', () => {
cb("Download successful.")
});
res.pipe(file);
})
})
req.on('error', error => {
console.error(error)
})
req.end()
}
Hope this helps.