0
@RestResource(urlMapping='/getTL/*')
global class WS_GetTLList {

      @HttpGet
    global static User doGet() {

    RestRequest req = RestContext.request;

     User user=new User();
    String MobileNo = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
    List<User> userList = new List<User>();
    List<External_Users__c> euList = new List<External_Users__c>();


    if(MobileNo != ''){
        euList =[SELECT Id ,Team_Leader_Name__c ,Mobile_Number__c from External_Users__c where Mobile_Number__c = :MobileNo];
    }
    if(euList.size() > 0 ){

       for(External_Users__c euser:euList )
       {
       user.Mobile=euser.Mobile_Number__c;
       user.SuperiorName=euser.Team_Leader_Name__c;

       }

      }

      return      user;       

    }



   global class User{
     String Mobile;
     String SuperiorName;
    }  

Test class

@isTest(seeAllData=false)
public Class WS_GetTLList_Test{
  User user=new User();

 static testMethod void GetRecords()
   {

    Test.startTest();
    RestRequest req = new RestRequest(); 
    RestResponse res = new RestResponse();

    req.requestURI = 'https://cs5.salesforce.com/services/apexrest/getTL/1234567890';  
    req.httpMethod = 'GET';
    RestContext.request = req;
    RestContext.response = res;        


     WS_GetTLList.doGet();
     List<External_Users__c> ListAcct = [SELECT Id ,Team_Leader_Name__c ,Mobile_Number__c from External_Users__c where Mobile_Number__c = :'1234567890'];        

    Test.StopTest();

  }


}    
New contributor
user63974 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

put on hold as off-topic by Novarg, Reshma, David Reed, Derek F, glls Feb 11 at 14:11

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it. For help writing short, self-contained syntactically-valid examples, see: SSCCE.org" – Novarg, Reshma, David Reed, glls
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Hi @user63974, can you please explain what is the issuing you are facing ? – Vijay Ganji Feb 11 at 7:07