
public with sharing class HTTPPosting {
HttpRequest req = new HttpRequest();
//Set HTTPRequest Method
req.setMethod('POST');
//Set HTTPRequest header properties
req.setHeader('content-type', 'application/json');
req.setHeader('Content-Length','1024');
req.setHeader('Accept','application/json');
req.setTimeout(120000);
req.setEndpoint('https://platform.modsolar.net/rest/createLead/{myAPIkeygoeshere}/');
//Set the HTTPRequest body
req.setBody('externalLeadId=ApptID__c&FName2__c=i360__Prospect_Name__c&Street__c=i360__Address__c&City__c=i360__City__c&State__c=i360__Prospect_State__c&Postal_Zip__c=i360__Zip__c&phone=i360__Prospect_Phone__c');
Http http = new Http();
try {
//Execute web service call here
HTTPResponse res = http.send(req);
//Helpful debug messages
System.debug(res.toString());
System.debug('STATUS:'+res.getStatus());
System.debug('STATUS_CODE:'+res.getStatusCode());
} catch(System.CalloutException e) {
//Exception handling goes here....
}
}
If you are doing this using the force.com IDE, you may find this helpful: http://salesforce.stackexchange.com/questions/45171/syntax-errors-in-eclipse