Download Email Attachments programatically

Hi Everyone, im trying to download an attachment file server side, i already have the url of the attachment, my problem is when i request the url of the file, instead of the file i receive the login page in my response, im aware that purecloud is asking credentials, but i dont know how can give the permissions and go direct to the download url.

I've tried this on nodejs and .net

the response i get this, tks

<script src="/assets/vendor-a7339bcda1e66254983845167e4c0a26.js" integrity="sha256-BrUmKDyQozF6vczWc55eh0vPVKJ/Q06bD

OzGr3mWhKg= sha512-QGPMZQF+/ge4ppBcztcar0dv/sB/AaAb7lF/cm7URNQ/5yAdzIfQVP14aLIse+pp0pzKNCgIVSl4cepvKjIukw==" >

Make sure you're sending the standard authorization header with your auth token with the download request. If you don't provide a valid auth token, you'll get the login page.

Hi Tim, sorry im a little lost here, this is my request, im using client credentials grant, should i sent the request with the token instead of this?

var auth = "Basic " + new Buffer(clientId + ":" + clientSecret).toString("base64");
const options = {
method: 'GET',
uri: 'https://api.mypurecloud.com/api/v2/downloads/ddc98260',
headers: {
"Authorization":auth
}
}

Yes, you should be sending the auth token with the request in the same manner you make any other authenticated request to the API. Your example is only valid when first obtaining an auth token for client credential and auth code grants; it is not valid for making authenticated API requests. See Client Credentials - Use the access token.

Thanks i resolved my problem, with your answer!

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