Notes
public static void PostCustomerFromContacts(){
List<Contact> conList = [SELECT Id, FirstName, LastName, Phone, Email FROM Contact];
List<CustomerRequest> customerList = new List<CustomerRequest>();
for(Contact con : conList){
CustomerRequest customer = new CustomerRequest();
customer.firstName =con.FirstName;
customer.lastName = con.LastName;
customer.email =con.email;
customer.phone=con.phone;
customer.gender='Male';
customer.status='active';
customerList.add(customer);
}
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api.pathtosalesforce.com/customer.php?token='+token);
request.setMethod('POST');
request.setBody(JSON.serialize(customerList));
request.setHeader('Content-Type', 'application/json;charset=UTF-8');
HttpResponse response = http.send(request);
System.debug(response.getStatusCode());
System.debug(response.getStatus());
System.debug(response.getBody());
}