Cannot connect to Salesforce custom domain


#1

Our salesforce org is hosted at a custom salesforce domain. Instead of NA15.salesforce.com for example, it is at companyname.my.salesforce.com

When I try to connect my Salesforce service I get the following error:
{
“error”: [
{
“context”: null,
“message”: “[curl] 6: Couldn’t resolve host ‘companyname.salesforce.com’ [url] https://companyname.salesforce.com/services/data/v29/sobjects/”,
“code”: 500
}
]
}

I think that the request needs to change the URL to https://companyname.my.salesforce.com/services/data/v29/sobjects/ but I’m not sure how to do that.


#2

Are you using an SDK to connect, if so, which one? Also, using any framework - angular, jquery?

You have to point the DSP_URL to the correct URL that you’d like to use.

Have a look there to see what I’m referring to.

Thanks,

Mark


#3

I haven’t gotten that far yet, just trying to execute test queries in the Live API. I was able to get my angular app configured with the DSP_URL, but wanted to actually validate that the query would work before I tried getting it working in my app.


#4

Okay - so what type of service are you adding to your DSP? How have you configured it? And what kind of queries are you able to get via the live api? Which ones don’t work?

Thanks,
Mark


#5

I was simply using the Salesforce service type in 1.7.6. I tried it with my production org and got the 404 error because of the way the name was resolving, but I also tried it using a sandbox and got a different error relating to bad credentials. I wasn’t able to get anything firing in the Live API with either one just yet. I’m going to try with another sandbox user and see if that isolates the issue to production’s My Domain issue.


#6

I was able to get properly authenticated by modifying htdocs/vendor/dreamfactory/lib-php-common-platform/src/Services/SalesforceDbSvc.php:

by adding .my
’https://%s.**my.**salesforce.com/services/data/%s/’,

I am able to successfully list tables via the DSP REST API, but now when I try to run a simple query like GET /salesforce/accounts I get a nasty 500 error that serves up a page inside of the response body.

I can post the whole error if needed, I just want to make sure there aren’t any keys that would be bad to share!


#7

It is part of our development backlog to make the login and URL fetching for the Salesforce class more flexible, so we can handle My Domain URLs like https://reilly3000.my.salesforce.com. (Salesforce even offers a setting to disallow logins from login.salesforce.com which would of course cause your DSP problems if it were enabled.)

Since you are comfortable editing your code, you only need to make two changes to hack together immediate functionality for a single My Domain org (e.g. https://reilly3000.my.salesforce.com). The file paths will vary depending on your install. The below paths are from an OS X Bitnami DSP install.


File #1 to edit:

/Applications/dreamfactory-1.8.2-1/apps/dreamfactory/htdocs/vendor/dreamfactory/lib-php-common-platform/config/templates/salesforce/salesforce.enterprise.wsdl.xml

Edit this:

<soap:address location="https://login.salesforce.com/services/Soap/c/28.0/0DF40000000CfJS" />

To this:

<soap:address location="https://reilly3000.my.salesforce.com/services/Soap/c/28.0/0DF40000000CfJS" />

File #2 to edit:

/Applications/dreamfactory-1.8.2-1/apps/dreamfactory/htdocs/vendor/dreamfactory/lib-php-common-platform/src/Services/SalesforceDbSvc.php

Edit this:

protected function getBaseUrl()
{
    return sprintf(
        'https://%s.salesforce.com/services/data/%s/',
        $this->_getServerInstance(),
        $this->_version
    );
}

To this:

protected function getBaseUrl()
{
    return sprintf(
        'https://reilly3000.my.salesforce.com/services/data/%s/',
        $this->_version
    );
}

#8

Woo that worked!!! Thanks very much!

It took me a long time because I didn’t notice to remove the $this->_getServerInstance();

However, it was a good use of time because I got to know the system much better, also I had an idea:
I ended up using a salesforce generated WSDL file and it works great. They have a nice UI for generating one and now it gives me the current API for my org ready to go. It may be handy to simply allow for those files to be uploaded straight into the DSP in the Services UI. That may cut down on maintenance work for you guys as their API evolves!