am trying to post the csv data through http post to end point url.
Below is my code.
string test = 'test1,test1@gmail.com'; // which will be get from DB and make as CSV string
String header = '--'+boundary+'\n'; //boundary is random string
String footer = '\n'+boundary+'--';
String bodyText = 'Content-Disposition: form-data; name="upload";'
+ '\nfilename="test.csv"'
+ '\nContent-Type: text/csv'
+ '\n' + test;
String body = header + bodyText + footer;
req.setHeader('Content-Type','multipart/form-data; boundary='+boundary);
req.setHeader('Content-Length',String.valueof(body.length()));
req.setMethod('POST');
req.setEndpoint(myendpoint);
req.setBody(body);
req.setTimeout(60000);
The problem is I couldn't able to post the data.
I make query from DB and make the data as CSV string.
Then put those CSV string in request body.
The requirement is I need to post the file.
Is it because the request can't be done successfully as I am making CSV string and put into request body?
Can anyone give me headstart?
I have been stuck on this problem quite long time now.
PS: I even tested whether my request header are right or not with posttestserver.com with REST client firefox plug in. Still can't post. Pls check out the test result. http://www.posttestserver.com/data/2013/07/01/01.18.49320686031