+ Start a Discussion
RAM RRAM R 

How to retrive accounts through query using rest api call from client or to my org ?

please suggest me , how to get this account from client org to my org using rest api through '/services/data/v35.0/query' endpoint?
Account accounts = [SELECT id from Account where Name ='sree'];
    req.setMethod('GET');
    req.setHeader('Authorization' , 'Autorization: Bearer' + accessToken);
    req.setHeader('Content-Type','application/json; charset=utf-8' );
    req.setEndpoint(instanceUrl+'/services/data/v35.0/query?'+accounts);
    Http http2 = new Http();
    HTTPResponse res2 = http2.send(req);   
    System.debug('****************res2.getbody(): '+res2.getbody());
Best Answer chosen by RAM R
AshlekhAshlekh
Hi,

You can user end point 

instanceUrl+"/services/data/v20.0/query/?q=SELECT+name+from+Account+where+name='sree'".

And you can see that q is a paramter, Remember to pass the SOQL as the 'q' parameter in the URL,and to URLEncode the soql when putting it in the query

-Thanks
Ashlekh Gera