You need to sign in to do that
Don't have an account?
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();
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.