0

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
3

I think you need to try this: /services/apexrest/SalesProduct/test-product.

Use the GET verb operation from Workbench.

|improve this answer|||||
  • Thanks thas was helpful. – Thomas Feb 28 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.