You need to sign in to do that
Don't have an account?
Meena25
REST API Post method
request.setBody('"lead":{"leadId":" "},{"firstName":"FN1"},{"lastName":"LN2"},{"ssn":"2"}');
I need to send values from salesforce to endpoint, am able to make the connection, however i see null values. I need to be able to pass more fields and corresponding values of lead object. Could someone help me how to use(send) multiple parameters in request.setBody?
I need to send values from salesforce to endpoint, am able to make the connection, however i see null values. I need to be able to pass more fields and corresponding values of lead object. Could someone help me how to use(send) multiple parameters in request.setBody?
List < LeadWrapper> lstLeadWrapper = new List < LeadWrapper> (); // Create a list if you want to send buld data
LeadWrapper leadWrapper = new LeadWrapper(l);
lstLeadWrapper.add(leadWrapper); // Iterate through your records and add to the list
Map < String, Object > objMap = new Map < String, Object > ();
objMap.put('lead', lstLeadWrapper );
String reqBody = JSON.Serialize(objMap);
system.debug('reqBody....' + reqBody);
req.setBody(reqBody);
public class LeadWrapper{
public String leadId;
public String firstName;
public String lastName;
public String ssn;
public LeadWrapper(Lead l){
this.leadId = l.id.
this.firstName = l.firstName;
this.lastName = l.lastName;
this.ssn = l.ssn
}
}
Let me know if this helps you.