You need to sign in to do that
Don't have an account?
praveenpro
how to send attachment from php to salesforce and how to insert attachment in salesforce using REST Api?
Hi,
@HttpPost
global static String createNewAttachments() {
RestRequest req = RestContext.request;
String optyName=req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
Opportunity objOpty= [ Select ID, Name from Opportunity where Name =:optyName limit 1];
String doc=EncodingUtil.Base64Encode(req.requestBody);
Attachment a = new Attachment();
a.ParentId = objOpty.Id;
a.Name = 'test.doc';
a.Body = req.requestBody;
a.ContentType = 'application/vsn.ms-word';
insert a;
return 'attachment added';
}
I am able get attachment using Apex REST Api form external system but the file data was not opened properly in the document.
@HttpPost
global static String createNewAttachments() {
RestRequest req = RestContext.request;
String optyName=req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
Opportunity objOpty= [ Select ID, Name from Opportunity where Name =:optyName limit 1];
String doc=EncodingUtil.Base64Encode(req.requestBody);
Attachment a = new Attachment();
a.ParentId = objOpty.Id;
a.Name = 'test.doc';
a.Body = req.requestBody;
a.ContentType = 'application/vsn.ms-word';
insert a;
return 'attachment added';
}
I am able get attachment using Apex REST Api form external system but the file data was not opened properly in the document.