Pass params to Salesforce Inbount REST API

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:

Leave a Reply