function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
gv007gv007 

Data is corrupting when send a multi part request to a third party server

Hi ,

      I am sending an http request to an third party server from salesforce ,here am using an httprequest  to post the data to third party server ,the data is documents to third party content management system I know the apex limitation 100kb ,am sending below 100kb am get only txt files now all other documents are corrupting I tried a lot using different any one can help me in this issue here is my code.

 

sending an http request to third party application using multipart.

 

 

 

String response; String boundary = 'AaBbCcX30'; String m_URL = 'some url'; String content = 'Content:\r\n--' + boundary + '\r\nContent-Disposition:form-data;name="' + p_fileName + '";filename="'+p_fileName+'"\r\n'; content +='Content-Type:' + p_fileContentType + ',charset=ISO-8859-1,*,utf-8\r\n'; content +='Content-Transfer-Encoding: binary\r\n\r\n'; content += p_fileBlob +'\r\n\r\n'; content += '--'+boundary+'--\r\n'; System.debug(p_fileBlob.size()+'content ' + content); Http m_http = new Http(); HttpRequest req = new HttpRequest(); req.setEndpoint(m_URL); req.setHeader('Content-Type','multipart/form-data;boundary='+boundary); req.setMethod('POST'); req.setBody(content); HttpResponse m_httpResp = null; m_httpResp = m_http.send(req); m_strHttpResp = m_httpResp.getBody();

 

 

almazanjlalmazanjl

Hi.

 

A little late, but if it could help someone else.

 

Try this solution. Valid for servers that only support binary content and for servers that support base64 encoding.

 

http://salesforceafondo.wordpress.com/2013/01/08/post-multipartform-data-out-of-salesforce-com-with-...

 

Hope this helps.

 

José Luis Almazán.