We are using Sales force REST API to handle our leads.Basically, REST api

We want to convert lead to account using REST API. But it seems that it is not possible using REST API.

As I see here SOAP API using SOAP it is possible but question is how can I do using REST API.


Sample Code

global with sharing class RestLeadConvert {            

global static String doGet() {
    String ret = 'fail';
    RestRequest req = RestContext.request;
    RestResponse res = RestContext.response;
    String leadId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);              
    Database.LeadConvert lc = new Database.LeadConvert();

    LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
    Database.LeadConvertResult lcr ;
        lcr = Database.convertLead(lc);
        ret = 'ok';
    catch(exception ex){
        system.debug('***NOT CONVERTED**');           
    return ret;

You can call above rest service using below url

<Your Instance URL>/services/apexrest/ConvertLead/<LeadId>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.