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

rest resource issue
@RestResource(urlMapping='/myrest2/*') global with sharing class Rest_Class2 { @HTTPGet global static Account[] doGet() { RestRequest req = RestContext.request; RestResponse res = RestContext.response; String currentIndustry=req.requestURI.substring(req.requestURI.lastIndexof('/')+1); Account[] acts=new Account[]{}; if (currentIndustry=='all') acts=[select Name,Industry from account where Industry=:currentIndustry]; else acts=[select Name from account where Industry=:currentIndustry]; return acts; } }Hi friends
I have written a rest resource where I want to display all account where Industry='Energy'. when I test this is work bench it is showing error as
Service not found at: /services/apexrest/industry/enerygy
If it do as /services/apexrest/industry/all then it will show all accounts
But either way its not showing records.
Pls guide me.
divya
/services/apexrest/industry/enerygy - Here is the mistake. Please refer below code for calling the @RestGet Annontation.
If your service is packaged please add your package namespace as I mentioned below:
Thanks,
Prem Anandh
All Answers
Might be your Org has a namespace and this you are missing in your Url.
I went to remote site settings but not sure of https or http.
Thanks
divya
/services/apexrest/industry/enerygy - Here is the mistake. Please refer below code for calling the @RestGet Annontation.
If your service is packaged please add your package namespace as I mentioned below:
Thanks,
Prem Anandh
Thanks, I did not have to perform remote site setting.
/services/apexrest/myrest2/energy works
But if I give /services/apexrest/myrest2/all it doesnt work. Am I missing anything?
Can you confirm if "all" value is available in Industry picklist?
If not added please add that value. I don't think if its there already.
I have added "all" to the industry picklist and its is reflecting when an new account is created.
In workbench I am giving /services/apexrest/myrest2/All but no data displayed.
Thanks
divya
its working