Skip to main content
Hi All,

I want veiw a case passing the respective casenumber, below the code REST API but its not working,

@RestResource(urlMapping='/CaseNumber/*')

global with sharing class CaseNumber{

@HttpGet

    global static List<Case> getCaseById() {

       RestRequest req = RestContext.request;

        RestResponse res = RestContext.response;

        String Casenumbers= req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);

          List<case> result =  [Select id, Case_Owner_Name__c, Type, Origin, Reason, OwnerId, Status, subject, IsClosed, Priority, AccountId, CSM_ID__c, ContactId, CaseNumber, ClosedDate, Description, IsEscalated, ContactPhone, ContactEmail from Case where CaseNumber= :CaseNumbers];

        return result;

    }

}

Can someone help me on this??

 
1 resposta
  1. 7 de ago. de 2018, 15:10
    YOUR code is working fine and i tested workbench 

    THIS IS YOUR ENDPOINT URI  and i pass the case number and i got the response 

     

    /services/apexrest/CaseNumber/00001034

    YOUR code is working fine and i tested workbench THIS IS YOUR ENDPOINT URI and i pass the case number and i got the response /services/apexrest/CaseNumber/00001034
0/9000