Legacy Dev Forum Posts

 View Only

Sign Up

Fetch Email attachment from Purecloud API url (contentURI) and store as file in Salesforce

  • 1.  Fetch Email attachment from Purecloud API url (contentURI) and store as file in Salesforce

    Posted 06-05-2025 19:01

    fransiska.hendra | 2022-06-16 03:50:34 UTC | #1

    Hi,

    If anyone can help me with this.

    I use PureCloud API /api/v2/conversations/emails/{conversationId}/messages, to get email contentURI: "attachments": [ { "attachmentId": "c9b3c6f2-ddb2-4c90-a3.....", "name": "xx.log", "contentUri": "https://api.mypurecloud.com.au/api/v2/downloads/0d......", "contentType": "application/octet-stream", "contentLength": 189561, "inlineImage": false }

    And I do httprequest in Salesforce to download this as a stream, as following:

    HTTP h = new HTTP(); String authorizationHeader = 'Bearer xxxxxxxxx'; HttpRequest req = new HttpRequest(); req.setEndpoint('https://api.mypurecloud.com.au/api/v2/downloads/0d0f.........'); req.setMethod('GET'); req.setHeader('Content-Type', 'application/octet-stream'); req.setHeader('authorization',authorizationHeader); HttpResponse res = h.send(req); String body = res.getBody(); system.debug('response: '+res.getStatus()); if(body=='') return 'empty'; else return body;

    And it always endedup with result Response 303 - See other, although I have put bearer token properly (PureCloud - oauth grant implicit).

    Thank you for help in advance. Fransiska


    tim.smith | 2022-06-16 19:50:06 UTC | #2

    That is correct. Please have your applicaiton follow the 303.


    fransiska.hendra | 2022-06-17 03:17:40 UTC | #3

    Thanks Tim for confirmation.

    Will come back if there's further query.

    Fransiska


    fransiska.hendra | 2022-06-20 04:20:18 UTC | #4

    hi @tim.smith ,

    Just wondering, what is PureCloud API to get this link of this attachment ? (see yelow highlight)...

    If i clicked this link, https://prod-apse2-recording-playback.s3.ap-southeast-2.amazonaws.com/MediaCache/37173e09-0828-4699-83ac-1905932f668a/......

    And if i use this link in the Salesforce Apex /REST API, it working i able to transfer file to Salesforce, not getting error 303 anymore.

    But is there any PureCloud API, that i can get result this link ?

    Thank you Fransiska


    system | 2022-07-21 04:21:05 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: 15177