MKP
MKP

Reputation: 13

Is there any way to get content of the ZenDesk Attachments instead of redirect URL?

I need to get ZenDesk ticket attachment content like encoded format. ZenDesk API provided only the content url. By using that content url I can only able to get the redirect page of that file. But I need to automate a process that file as Base64 encoded format. Thanks in advance. Note : I tried to migrate ZenDesk to Salesforce via Dell Boomi.

Upvotes: 0

Views: 975

Answers (1)

Carlos Carvalho
Carlos Carvalho

Reputation: 1

I found a resolution for my problem and I guess it's the same as yours.

In salesforce apex code I got the url response from zendesk and I used subtring method to get URL of attachment. After that I used Pagereferece to open the URL, see below:

String exampleMyResponse= '<html><body>You are being <a href="https://xxx.zdusercontent.com/attachment/000001/sdlfkashdf98709udfah?token=eyJhbGciOiJkaX46SgYrFzTEpYqUIzpQeNnl5BMBNoRnUOsgQj389Ei7nNcGOcfGYaavlqLL2qaIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0..U8oX8QnYBM1lZMb6rhQGRA.NC3Z9kHC9ZE6HhygIHHan6xWYvoPqziVx76CZ6vcNYHBuAjV-LmBclVJYumKWKXA_PDhXX27z977XKYrLJZSc85a6lJTEqd-V2mP7U6O6r0_6E9hO8CWaA1dyxYYWw8kUsgMFUaPr0wCupxm3NbDzT03ZwO6EBJj79x4UZdauiXfEUrSwdl1pPahlQE2VfFo8DprgX9GQHzRFm5lwMrhA3crogo8Ox';


**//You need to authorize your domain "https://xxx.zdusercontent.com"** in remote site

Pagereference pg = new Pagereference(exampleMyResponse.substringAfter('href="')); 

**Blob b = pg.getContentAsPDF();**//Here you can use getContent() too for another type of file

//Example to save PDF

Attachment att = new Attachment(Name = 'stvm_4', Body = b, ContentType = 'application/pdf', ParentId='Sobject_Id');

insert att;

Upvotes: 0

Related Questions