You need to sign in to do that
Don't have an account?
si ri
how to check what response is coming for this restrequest class ?
@RestResource(urlMapping='/installs/*')
global class InstallRestAPIs {
@HttpGet
global static Installation__c getInstall( ){
Installation__c instl;
try{
RestRequest req= RestContext.request;
String accountId= req.requestURI.substring(req.requestURI.lastindexOf('/')+1);
system.debug('sfAccountId: '+ accountId);
instl = [select Time_Zone__c from Installation__c where id= :accountId and status__c = 'Installed'];
}catch(Exception e){
system.debug('Error in fetching Account'+e.getMessage());
}
return instl;
}
}
Can anyone help? Thanks in advance
global class InstallRestAPIs {
@HttpGet
global static Installation__c getInstall( ){
Installation__c instl;
try{
RestRequest req= RestContext.request;
String accountId= req.requestURI.substring(req.requestURI.lastindexOf('/')+1);
system.debug('sfAccountId: '+ accountId);
instl = [select Time_Zone__c from Installation__c where id= :accountId and status__c = 'Installed'];
}catch(Exception e){
system.debug('Error in fetching Account'+e.getMessage());
}
return instl;
}
}
Can anyone help? Thanks in advance
SELECT Time_Zone__c from Installation__c WHERE Id= :accountId and Status__c = 'Installed'
Actually, In WHERE condition you're filtering the records with Id (Installation object Id) with Account Id. I believe that cannot be same.
Confirm this from your side too.
All Answers
Refer this link
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_restrequest.htm?search_text=restreq
You can use workbench to check response for this Apex webservice.
1. login to : https://workbench.developerforce.com/login.php
2. Goto : Utilities --> REST Explorer
3. Choose : Method --> GET
4. URL : /services/apexrest/installs/<AccountID>
Let us know if this will help you.
Thanks,
Govindaraj.S
I'm getting error by the above URL : /services/apexrest/installs/<AccountID>
Hi Raj Vakati,
I have tested your code in Anonymous window like :
InstallRestAPIs obj= new InstallRestAPIs ();
InstallRestAPIs .getInstall();
but in log file the response is showing Null
In the URL : /services/apexrest/installs/<AccountID>
<AccountID> : You need to give the id of the Account which used for testing. for generic purpose i mentioned <AccountId>
For example : /services/apexrest/installs/00128000002jrWf
Thanks,
Govindaraj.S
SELECT Time_Zone__c from Installation__c WHERE Id= :accountId and Status__c = 'Installed'
Actually, In WHERE condition you're filtering the records with Id (Installation object Id) with Account Id. I believe that cannot be same.
Confirm this from your side too.
Provide the Apex class access to the profile (the one which you used to login the workbench).
This might help you : https://developer.salesforce.com/forums/?id=9060G0000005qPYQAY
Thanks,
Govindaraj.S
Govinda Raj S
Your tip was very helpful, i have done my work.
Thank you