You need to sign in to do that
Don't have an account?
s_mac
Steps to call apex rest service from workbench rest explorer
I have created apex rest service and I am calling it from workbench rest explorer,but I am getting an error
Created the following class
@RestResource(urlMapping='/Account/Contacts')
global with sharing class AccountManager{
@HttpGet
global static Account getAccount(){
RestRequest request = RestContext.request;
// grab the caseId from the end of the URL
String AccountId= request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
/*Account result = [SELECT Id,Name,(Select Name from Contacts) FROM Account
WHERE Id = :AccountId]; */
Account result = [SELECT Id,Name FROM Account WHERE Id = :AccountId];
return result;
}
}
And then when
I am giving the url as /services/apexrest//Account/Contacts/<AccountID>
Error is: Service not found at: /services/apexrest/Account/Contacts/001......
Can some body please help me,why is this error or with the steps to followed..
Thanks in Advance...
Created the following class
@RestResource(urlMapping='/Account/Contacts')
global with sharing class AccountManager{
@HttpGet
global static Account getAccount(){
RestRequest request = RestContext.request;
// grab the caseId from the end of the URL
String AccountId= request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
/*Account result = [SELECT Id,Name,(Select Name from Contacts) FROM Account
WHERE Id = :AccountId]; */
Account result = [SELECT Id,Name FROM Account WHERE Id = :AccountId];
return result;
}
}
And then when
I am giving the url as /services/apexrest//Account/Contacts/<AccountID>
Error is: Service not found at: /services/apexrest/Account/Contacts/001......
Can some body please help me,why is this error or with the steps to followed..
Thanks in Advance...
1) http://amitsalesforce.blogspot.com/2016/04/rest-api-in-salesforce-execute-rest-api.html
Do minar change your code like below :- I just added * in your URL
Your URL should be :- /services/apexrest/Account/Contacts/<AccountID>
Method :- Get
Ley us know if this will help you
Thanks
Amit Chaudhary
All Answers
1) http://amitsalesforce.blogspot.com/2016/04/rest-api-in-salesforce-execute-rest-api.html
Do minar change your code like below :- I just added * in your URL
Your URL should be :- /services/apexrest/Account/Contacts/<AccountID>
Method :- Get
Ley us know if this will help you
Thanks
Amit Chaudhary
/services/apexrest/namespace/Account/Contacts/001...
Error is: Service not found at: /services/apexrest/Account/Contacts/001......
Remove that extra "/" and try like below :
/services/apexrest/Account/Contacts/<AccountID>
Try this :
I will recommend you to please start new thread for new issue. So that other can also help you
Well you can try below code.
Let us knw if this will help you
GET /services/data/v36.0/sobjects/Account/{id}/contacts
More info here: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_relationships.htm
I am having similar problem. I am making POST request to my REST API. I also have managed package. I amm getting the following error with workbench : Service not found at: /services/apexrest/My_Package/zendeskAPI
@RestResource(urlMapping='/zendeskAPI/*')
global with sharing class zendeskAPI {
@HttpPost
global static String doPost(){
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String reqBody = req.requestBody.toString();
return reqBody;
}
}
can anyone please help