Activity Forums Salesforce® Discussions How to get bulk records in Rest API using rest class and by using Wrapper class in salesforce

  • sushant

    January 19, 2017 at 1:56 pm

    Hi vikas,

    You can try the following code for this:

    global with sharing class campclass{
    global static List<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];

    List<Accountwrapper> accWrapList = new List<Accountwrapper>();
    for(Account acc : result){
    Accountwrapper accWrap = new Accountwrapper();
    accWrap.accId = acc.Id;
    accWrap.Name = acc.Name;
    accWrap.Phone = acc.Phone;
    accWrapList .add(accWrap);
    return accWrapList ;
    global class Accountwrapper {
    Public Id accId;
    public String Name;
    public String Phone;



Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos