+ Start a Discussion
Venkateswarlu ChVenkateswarlu Ch 

How to use /services/data/v33.0/queryAll/?q=SELECT+Name+from+Account

I have two salesforce orgs A and B. I am want to get all Account records there in B org in Org A. I written code REST API. Eevrything workig fine. But how to user pass: /services/data/v29.0/queryAll/?q=SELECT+Name+from+Account. this use this funciton in REST API.

Below is my Code:

public class W_RestInvoke_Account2c{
    public String result{set;get;}
    fromJSON d1 {set;get;}
   // JSON2Apex d2            {set;get;}
    public String d3        {set;get;}     
    public String accesstkn {set;get;}     
    Account accrec          {set;get;}

public String clientid ;  

public void show(){

    Http p =new Http();
    HttpRequest request=new HttpRequest();
    request.setBody('grant_type=password&client_id=tw&client_secret=7925616023235447130&username=cxxxm&password=xxx' );
    HttpResponse res=p.send(request);
  //string tknAccesstoken = (String) res.getAttribute(ACCESS_TOKEN); 

        d1 = (fromJSON)JSON.deserialize(result, fromJSON.class);
accesstkn = d1.access_token;
system.debug('VENKATESH______-->fromJSONvalues:Y'+ accesstkn );

HttpRequest request1= new HttpRequest();
request1.setHeader('Authorization','OAuth '+accesstkn);
HttpResponse response=p.send(request1);
result= ''+response.getBody();


public class fromJSON{
public String id;   
public String issued_at;    
public String token_type;   
public String instance_url; 
public String signature;    
public String access_token; 


Pls help me where can use this /services/data/v29.0/queryAll/?q=SELECT+Name+from+Account function?
Best Answer chosen by Venkateswarlu Ch
you have to set the end point as 

Are you going to do this one time or going to schedule it?

if it is one time, you could just export from org 1 and import in org2 using data loader.

if you want to share the data, then you can look into salesforce to salesforce.

if you want to scehdule your code above, you should not be selecting all the account each time it runs, you can get only new record and modified records and the upsert it  to another org.