I have a webservice and want to test this in workbech but get the error:
[ { "errorCode" : "NOT_FOUND", "message" : "The requested resource does not exist" } ]
webservice
@RestResource(urlMapping='/SalesProduct/*')
global with sharing class WebserviceSalesproducts {
@HttpGet
webservice static List<Sales_Product__c> getSalesproductsByProductCode() {
RestRequest request = RestContext.request;
RestResponse response = RestContext.response;
List<Sales_Product__c> result= new List<Sales_Product__c>();
String ProductCode = request.requestURI.substring(request.requestURI.lastIndexOf('/')+1);
system.debug('ProductCode '+ ProductCode);
try{
Sales_Product__c SprResult = [SELECT id,name, Productcode__c
FROM Sales_Product__c
WHERE Productcode__c = :ProductCode ];
result.add(SprResult);
}catch(exception e){
system.debug('Error'+ e);
}
system.debug(result);
if(result.size()==0){
response.statusCode = 204;
response.responseBody = blob.valueOf('Sorry no match');
}
if(result.size()>0){
return result;
}Else{
return null;
}
}
}
Workbench rest explorer url:
/services/data/v47.0/sobjects/SalesProduct/test-product