+ Start a Discussion
GAURAV SETHGAURAV SETH 

Which API to be used for Lead Management System to send qualified Leads as Accounts, Contacts and Opportunities to Salesforce

An external Lead Management system will send qualified Leads as Accounts, Contacts and Opportunities to Salesforce. Would you recommend the external system to integrate directly with the SFDC SOAP/REST API? Would you expose an Apex Webservice? What other integration pattern would your recommend and why? 
AnudeepAnudeep (Salesforce Developers) 
Hi Gaurav, 

You can either expose your class as a REST Service or SOAP Service. While making your Apex class available as a REST web service is straightforward it really depends on your external system as to which method it supports

To learn more refer to the documentation Apex Web Services

Note that you can create multiple objects at once when you expose your class. See example below
 
//Apex Class

@RestResource(urlMapping='/Accounts/*/contacts')
global with sharing class AccountManager{
    @HttpGet
    global static Account getAccount(){
        RestRequest request = RestContext.request;
        String accountId = request.requestURI.substringBetween('Accounts/','/contacts');
        system.debug(accountId);
        Account objAccount = [SELECT Id,Name,(SELECT Id,Name FROM Contacts) FROM Account WHERE Id = :accountId LIMIT 1];
        return objAccount;
    }
}

Let me know if this helps. If it does, please mark this answer as Best. It may help others in the community. Thank You!