function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
seamas liseamas li 

Can't see parameters in Rest HTTP doGet Method

Hi Expert,

I can not get phoneNumber in testing. but it is working in WorkBeach 

  @HttpGet
    global static String doGet() {
    
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;

        String phoneNumber = req.params.get('phoneNumber');
        String subscriptionId = req.params.get('subscriptionId');    
        system.debug('phoneNumber : '+ phoneNumber) ;  


        return response;
    }

    static testMethod void getSubscriptionByPhoneNumberTest() {
        
        test.startTest();        
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
        req.requestURI = '/services/apexrest/subscriptions?phoneNumber=416360999 1234567891 0488888888';
        req.httpMethod = 'GET';
        
        RestContext.request = req;
        
        String result=NewsSubscriptionController.doGet();

  
        test.stopTest();
    
    }
KaranrajKaranraj
Try avoiding space in the requestURI
req.requestURI = '/services/apexrest/subscriptions?phoneNumber=416360999+1234567891+0488888888';