Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Salesforce by (11.9k points)

I have an APEX Method that attempts to Post a form to a remote endpoint out of SFDC's APEX Code.

Everything seems to encode correctly, and the server sends back a 200 response, but the attachment isn't arriving with the request... is SFDC removing the content of my post body before it's sent?

HttpRequest req = new HttpRequest();

req.setHeader('Authorization','Basic '+EncodingUtil.base64Encode(Blob.valueOf('removed:removed')));

req.setHeader('Content-Type','multipart/form-data; boundary=-----------------------------153501500631101');




String body = '-----------------------------153501500631101\r\n';

body = body + 'Content-Disposition: form-data; name="Filedata"; filename="'+attachments[0].Name+'"\r\n';

body = body + 'Content-Type: '+attachments[0].ContentType+'\r\n';

body = body + 'Content-transfer-encoding: base64\r\n\r\n';

body = body + attachments[0].Body+ '\r\n';

body = body + '-----------------------------153501500631101--\r\n';


1 Answer

0 votes
by (32.1k points)

Try the solution in this link. It's a messed up solution with Blob+HttpResponse I've proposed.

To learn in-depth about Workflow in Salesforce, sign up for an industry based Salesforce Course.

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94.1k users

Browse Categories