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

Adding records from one org to another
Hi,
All I want to do is login to org1 and press a button that adds an Account to org2 (all I need in response is the Id of the record that was created). I am basically lost with all the different information on the web. I'm currently using user+pass for authentication in my HttpRequest POST call and it's giving me back an invalid session id error. Here are some of the resources that I have read through:
http://www.salesforce.com/us/developer/docs/api_rest/api_rest.pdf
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_rest_intro.htm
There's all these talks about tokens, OAuth, session id, remote access services, etc. which have completely lost me.
Here's my method:
public String sendToOrg(String j, String url, String user, String pass) { HttpRequest req = new HttpRequest(); req.setMethod('POST'); req.setEndpoint(url); req.setBody(j); Blob headerValue = Blob.valueOf(user + ':' + pass); String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue); req.setHeader('Authorization', authorizationHeader); Http http = new Http(); HTTPResponse resp = http.send(req); system.debug('**** Response: ' + resp.getBody() ); if (resp != null && resp.getBody() != null) return resp.getBody(); else return null; }
with url being: https://na4.salesforce.com/services/data/v24.0/sobjects/Account/
I'd really appreciate a straight-forward, Apex oriented guidance!
Hi ,
You can achieve it using METADATA WSDL.For login into org2 from org 1 use the partner WSDL of org2,generate the APEX class from it and call the login() method of the generated class.With this ,you can obtain the session id.
Now parse and generate the apex class from metadata wsdl.Instantiate this class,add the session id to the session header property of it.Instantiate the createfield class of the metadata class and create the field with the required fields value.