You need to sign in to do that
Don't have an account?

How to test an Apex class that uses @HttpGet
Hi,
I have a Get method that receives data through a URL:
I need to create a test class for my class, however I can not pass any parameters to the method because using GET does not accept.
Could someone help me with this question?
Thanks
I have a Get method that receives data through a URL:
@RestResource(urlMapping='/Contract/*') global class ContractREST { @HttpGet global static String getContratos() { RestRequest req = RestContext.request; RestResponse res = RestContext.response; String ContractId= req.requestURI.substring(req.requestURI.lastIndexOf('/')+1); Contract result = [SELECT Id , Regra_Separacao_Cartao__c, Origem_Contrato__c from Contract where Id =: ContractId ]; . . . JSONGenerator gen = JSON.createGenerator(true); gen.writeStartObject(); gen.writeStringField('Id',result.Id); gen.writeEndObject(); String jsonS = gen.getAsString(); return contractJSON; } }
I need to create a test class for my class, however I can not pass any parameters to the method because using GET does not accept.
Could someone help me with this question?
Thanks
All Answers
Thanks for the help, I managed to make it work by adjusting in some specific points.
Best regards.