+ Start a Discussion
Jeff JobsJeff Jobs 

Method does not exist or incorrect signature: getBuilder(String, RestRequest) for REST API Apex Class

Hello Everyone,

This is the first time I've attempted to create a REST API layer for my Salesforce ORG.  I'm trying to allow my ORG to receive a REST URI and return a list of Builders (which are Accounts).  The error I get when I try to save this code in the SF Developer Console is:  Method does not exist or incorrect signature: getBuilder(String, RestRequest)

Any assistance you could provide would be greatly appreciated!  Code is below:

@RestResource(urlMapping='/v.1/builders/*')
global with sharing class RESTAPI_MYSQL_Builders {
    
    @HttpGet
    global static List<Account> doGet(RestRequest req, RestResponse res) {
        
        String name = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        
        if(name != 'builders') {
            
            return getBuilder(name, req);
        }else {
            
            return getBuilders(req);
        }
    }
    
    private static List<Account> getBuider(String name, RestRequest req) {
        
        //Set Defaults
        String qryFields = 'id, name';
        //Set fields to return (If Available)
        if(req.params.containsKey('fields')) qryFields = req.params.get('fields');
        
        return Database.query('select ' + qryFields + ' from Account where name = \'' + name + '\'');
    }
    
    private static List<Account> getBuilders(RestRequest req) {
        
        //Set Defaults
        String qryFields = 'id, name';
        String qryLimit = 'limit 100';
        String qryOrderby = '';
        String qryWhere = '';
        
        //Set fields to return (If Available)
        if(req.params.containsKey('fields')) qryFields = req.params.get('fields');
        if(req.params.containsKey('limit')) qryLimit = 'limit' + req.params.get('limit');
        if(req.params.containsKey('orderby')) qryOrderby = 'order by' + req.params.get('orderby');
        if(req.params.containsKey('search')) qryWhere = 'where name LIKE \'' + req.params.get('search') + '%\'';
        
        return Database.query('select' + qryFields + ' from Account ' + qryWhere + ' ' + qryOrderby + ' ' + qryLimit);
    }
}
Best Answer chosen by Jeff Jobs
Shaijan ThomasShaijan Thomas
private static List<Account> getBuider(String name, RestRequest req) {, --> typo error, getBuilder
Thanks
Shaijan

All Answers

Shaijan ThomasShaijan Thomas
private static List<Account> getBuider(String name, RestRequest req) {, --> typo error, getBuilder
Thanks
Shaijan
This was selected as the best answer
Jeff JobsJeff Jobs
Thanks Shaijan!!  I must have looked at that 1000 times but just couldn't see it.