cancel
Showing results for 
Search instead for 
Did you mean: 

Has anyone been able to login through /api/rd/v1/Core/LoginFromSalesforce

eacr
Discoverer
0 Kudos
351

Hello Community, I've been exploring the /api/rd/v1/Cart API but we need to login from Salesforce in order to have all CPQ functionality and SFEnvironment. Has anyone been able to connect the API through this API /api/rd/v1/Core/LoginFromSalesforce? I keep getting {"Message":"Invalid login"} response.

I've been trying on Salesforce Developer Console > Execute Anonymous prompt with no success for a while now.

Thanks a lot.

String cpqHost = 'rssandbox.webcomcpq.com';
String cpqDomain = '<domain>';
String oppId = '<OpportunityId>';

String endpoint = 
    'https://' + cpqHost + '/api/rd/v1/Core/LoginFromSalesforce?' +
    'sessionId=' + UserInfo.getSessionId() + 
    '&sfApiUrl=' + URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/u/54.0/' + UserInfo.getOrganizationId() + 
    '&sfApiPassword=Password' +
    '&domainName=' + cpqDomain + 
    '&opportunityId=' + oppId
    ;

System.debug('Endpoint: ' + endpoint);

String reqBody = '';
Http h = new http();
HttpRequest req = new HttpRequest();
req.setEndpoint(endpoint);
req.setMethod('POST');
req.setHeader('Content-Length', String.valueOf(reqBody.Length())); 
req.setHeader('Accept', 'application/json'); 
req.setTimeout(60000);
req.setBody(reqBody);

HttpResponse res = h.send(req);
System.debug('Response Status:  ' + res.ToString());
System.debug('Response Body:  ' + res.getBody());
View Entire Topic
yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi eacr

Not possible if you use rssandbox** because that should go through SAML Based Authentication.
Try with your actual domain like eusb.* or sandbox.*
eacr
Discoverer
0 Kudos

Thanks Yoganda. I tried with 'sandbox', also tried with 'www' in production. Same message.

eusb doesn't find the domain but that's ok, we don't have eusb.

Tried matching the partner API version with the one used by the admin account, the latest and the one generated with the code above and no luck.

Regards.