I am new this rest api concept in salesforce and i tried my best to get my requirement. What my requirement is
I want to return account fields like id, name, phone and industry(and etc) using wrapper class only. i tried with following class and this class is returning only one record, not all the records which meets the condition.
REST Class:
@RestResource(urlMapping='/wrapper/*')
global with sharing class campclass{
@HttpGet
global static Accountwrapper doget() {
RestRequest req = RestContext.request;
String accphone = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
RestResponse res = RestContext.response;
List<Account> result = [Select Id, name,phone from account where phone=:accphone];
System.debug('Result:::'+result);
Accountwrapper accWrap = new Accountwrapper();
for(Account acc : result){
accWrap.accId = acc.Id;
accWrap.Name = acc.Name;
accWrap.Phone = acc.Phone;
}
return accWrap;
}
global class Accountwrapper {
Public Id accId;
public String Name;
public String Phone;
}
}
Could any help me please, how to get bulk records by using above class.
Thanks and regards.