[SalesForce] Rest API Session ID SOAP Partner Connection

I have a REST access token and would like to use that access token in my PartnerConnection ConnectionConfig to make a Bulk API call. It does not seem to work as I get an message to set my Service Endpoint. Please assist if it is possible to make a SOAP call from a REST access token?And how I can do it.

Best Answer

Yes you need to provide the service end point, if you logged in with Salesforce WSC (Web Service Connector) this is usually handled for you or returned in the LoginResult if you took the manual login route. If not you can set it manually like so.

ConnectorConfig partnerConfig = new ConnectorConfig();              
partnerConfig.setServiceEndpoint("https://yourinstance.salesforce.com");
partnerConfig.setSessionId(yourSessionId);
ParnterConnection partnerConnection = Connector.newConnection(partnerConfig);

Note: Its not usually a good idea to hard code your instance name. I assume when forming the REST URL's you've already resolved this in a way that is satisfactory for your situation.

Related Topic