我有一个 APEX 方法,它尝试使用SFDC 的 APEX 代码将表单发布到远程端点。
一切似乎都正确编码,服务器发回了 200 响应,但附件没有随请求一起到达……SFDC 是否在发送之前删除了我的帖子正文的内容?
HttpRequest req = new HttpRequest();
req.setHeader('Authorization','Basic '+EncodingUtil.base64Encode(Blob.valueOf('removed:removed')));
req.setHeader('Content-Type','multipart/form-data; boundary=-----------------------------153501500631101');
req.setHeader('X-Atlassian-Token','nocheck');
req.setMethod('POST');
req.setEndpoint(endPoint+'issue/'+c.Internal_Bug_Number__c+'/attachments');
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';
req.setBody(body);