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

Create a RestFul WebService, to Fetch all the Opportunities based on the Specified Account Name? below code is correct? i
@RestResource(URLMapping = '/OpportunityService/*')
global class OpportunityRecord
{
@HttpGet()
global static list<Opportunity> GetOpportunityRelated ()
{
Map<string, string> inputParams = RestContext.request.Params;
list<Opportunity> lstOpportunity = [select id,name, amount, stagename, closedate, accountId, Account.Name
from Opportunity where Account.Name =: inputParams.Get('accName')];
return lstOpportunity;
}
global class OpportunityRecord
{
@HttpGet()
global static list<Opportunity> GetOpportunityRelated ()
{
Map<string, string> inputParams = RestContext.request.Params;
list<Opportunity> lstOpportunity = [select id,name, amount, stagename, closedate, accountId, Account.Name
from Opportunity where Account.Name =: inputParams.Get('accName')];
return lstOpportunity;
}
}
Please try the below code:
/services/apexrest/OpportunityService?accName=MentionYourAccountNameHere
Reference Link : https://www.biswajeetsamal.com/blog/read-rest-api-get-parameters-in-apex-class/
Thanks,
Maharajan.C