You need to sign in to do that
Don't have an account?
aboussaidi
Add a PDF File to HttpRequest 'POST' REST
Hi,
I wana to delivre (send) a PDF file to externe Web Service using HttpRequest 'POST' (with REST), and i dont know how i must proceed.
hat's wath i have do at now :
String Id ='500S00000012tjM';
PageReference pageRef = new PageReference('/apex/GenererPDF?id='+Id);
Blob PDF = pageRef.getContentAsPDF();
String endpointSend = 'https://WebServiceTEst';
HttpRequest reqSend = new HttpRequest();
reqSend.setEndpoint(endpointSend);
reqSend.setMethod('POST');
Blob headerValueSend = Blob.valueOf(usrName + ':' + psswd );
String authorizationHeaderSend= 'Basic ' + EncodingUtil.base64Encode(headerValueSend);
reqSend.setHeader('Authorization', authorizationHeader);
reqSend.setHeader('content-type', 'application/pdf');
//String BlodPDF = EncodingUtil.base64Encode(PDF);
System.debug('22222222' + EncodingUtil.base64Encode(PDF));
reqSend.setBody(EncodingUtil.base64Encode(PDF));
Http httpLoadPDF = new Http();
HTTPResponse responseLaodPDF = httpLoadPDF.send(reqSend);
System.debug('STATUS:'+responseLaodPDF.getStatus());
System.debug('STATUS_CODE:'+responseLaodPDF.getStatusCode());
System.debug('333333' + responseLaodPDF.getBody());
Hi,
Did you find a work around to acheive this. I have a similar use case and looking for a solution. Please share your idea if you have achieved this.
Thanks,
Suresh.