August 17, 2021

Pass params to Salesforce Inbount REST API

Sample Code:
@RestResource(urlMapping='/InboundRESTAPI/*')
global with sharing class InboundRESTAPIController {

    @HttpGet
    global static Account fetchAccount() {
        
        RestRequest req = RestContext.request;
        Map < String, String > params = req.params;
        Id accId = params.containsKey( 'accId' ) ? params.get( 'accId' ) : null;
        return [ SELECT Id, Name, Industry, AccountNumber FROM Account WHERE Id =: accId ];
    
    }
 
}


Output:



No comments:

Post a Comment