• Boman-RMA
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies

Having figured that I cannot save a PDF retrieved from an external webservice as an Attachment in SFDC (callouts do not support binary), was wondering what workarounds or other options are available?

 

All I was attempting was:

 

 

Http h = new Http();
HTTPRequest req = new HttpRequest();       
req.setEndpoint('http://someserver/sample.pdf');
req.setMethod('GET');
HTTPResponse resp = h.send(req);
String body = resp.getBody();
Attachment attach = new Attachment();
try {
    attach.Body = Blob.valueOf(body); 
    attach.Name = 'PDF Quote';
    attach.ParentId = this.contact.Id;
    attach.ContentType = resp.getHeader('Content-Type');
    attach.IsPrivate = false;			
    insert attach;
} catch (DMLException e) {
    ApexPages.addMessages(e);
}

 All works fine. The attachment is saved. But, is never readable as a valid PDF. Any suggestions? Thanks.

 

I need to invoke a 3rd Party webservice that then returns to me the location of a Zip'd file from within which I need to extract the CSVs for processing.

 

Is there any suggested pattern for doing this? Would my only option be to transfer the Zip file to an intermediate server for unzipping, and then invoke a webservice hosted on that server tgo retrieve the contained CSVs? Thanks.

 

--Boman.

Having figured that I cannot save a PDF retrieved from an external webservice as an Attachment in SFDC (callouts do not support binary), was wondering what workarounds or other options are available?

 

All I was attempting was:

 

 

Http h = new Http();
HTTPRequest req = new HttpRequest();       
req.setEndpoint('http://someserver/sample.pdf');
req.setMethod('GET');
HTTPResponse resp = h.send(req);
String body = resp.getBody();
Attachment attach = new Attachment();
try {
    attach.Body = Blob.valueOf(body); 
    attach.Name = 'PDF Quote';
    attach.ParentId = this.contact.Id;
    attach.ContentType = resp.getHeader('Content-Type');
    attach.IsPrivate = false;			
    insert attach;
} catch (DMLException e) {
    ApexPages.addMessages(e);
}

 All works fine. The attachment is saved. But, is never readable as a valid PDF. Any suggestions? Thanks.