You need to sign in to do that
Don't have an account?
Mhlangano Khumalo
How to insert a record with multiple attachments in SFDC using REST
Below is my class.
@RestResource(urlMapping='/V1/IndividualKYC/*') global with sharing class IndividualKYCManager { //Create @HttpPost global static String createIndividualKYC(String a,Boolean termsandconditions,String phone, String idnum, String name,String photo, String email, ID entity, String address1, String address2, String suburb, String nationality, Integer postcode, String summary) { Individual_KYC__c ikyc= new Individual_KYC__c (); ikyc.Name=name; ikyc.Email__c=email; ikyc.ID_Number__c=idnum; ikyc.Phone__c=phone; ikyc.Terms_and_Conditions__c = termsandconditions; ikyc.Address_Line_1__c = address1; ikyc.Address_Line_2_Optional__c= address2; ikyc.Suburb__c= suburb; ikyc.Nationality__c= nationality; ikyc.Post_Code__c= postcode; ikyc.Profile_Summary__c= summary ; string before = photo; Blob beforeblob = Blob.valueOf(before); string paramvalue = EncodingUtil.base64Encode(beforeblob); ikyc.Photo__c = paramvalue ; insert ikyc; String ikycid=ikyc.id; return ikycid; } global void createAtt(String ikycid) { String pId=ikycid; string before2 = 'Testing base 64 encode'; Blob beforeblob = Blob.valueOf(before2); string paramvalue = EncodingUtil.base64Encode(beforeblob); //System.debug(before2 + ' is now encoded as: ' + paramvalue); Attachment attachmet = new Attachment (ParentId = pId, Body = EncodingUtil.base64Decode(paramvalue), ContentType = 'application/vnd.ms-excel', Name = 'SendViaMyPhone'); insert attachmet ; } }I want to insert a record & create 2 attachments in one POST. The challenge is wont allow me to have 2 inserts (ikyc & attachmet) in one method (createIndividualKYC), which is why i've split them. Im looking for a way to insert a record with 2 attachements (pdf. & jpg.) In one POST.
And the query in JSON looks like this
All Answers
What do you mean "the challenge?"
And the query in JSON looks like this
http://www.khumalomhlangano.com/#!Creating-an-httpPost-with-multiple-files-using-Rest-API/cn2s/564e08660cf2757a372ea6b5