I am trying to upload to JIRA from SF. I am using below code.
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
Blob headerValue = Blob.valueOf(username+':'+password);
String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
req.setHeader('Content-Type','multipart/form-data; boundary=--aRandomString_with_signs_or_9879497q8w7r8number--');
req.setHeader('Authorization', authorizationHeader);
req.setHeader('X-Atlassian-Token','nocheck');
String endpoint = 'http://jira.cimm2.com/rest/api/2/issue/TP-140/attachments';
req.setMethod('POST');
string message1= '--aRandomString_with_signs_or_9879497q8w7r8number\n';
message1+= 'MIME-Version: 1.0\n';
message1+= 'MIME-Type: text/plain';
message1+= 'Content-Disposition:attachment;name="file"; filename="cust-serv.pdf"; \n';
message1+= 'Content-Type: application/pdf; charset=UTF-8';
message1+= 'Content-Transfer-Encoding: binary\n';
message1+= 'Content-Length: 1200\n';
message1+= '\n';
message1+= +'Hello How Are You';
message1+= '\n\n';
message1+= '--aRandomString_with_signs_or_9879497q8w7r8number--\n';
req.setbody(EncodingUtil.urlEncode(EncodingUtil.base64Encode(blob.valueOf(message1)),'UTF-8'));
req.setEndpoint(endpoint);
res = http.send(req);
I am able to get status code as 200, but when i see in JIRA no attachments are there.
Can any one help me where i am doing wrong