You need to sign in to do that
Don't have an account?
trying to connect to our Sandbox with API using PERL
Hello all,
I am attempting to make a connection to our SandBox environment programatically with the API.
When I connected to our production environment, I did so using PERL as follows:
use WWW::Salesforce::Simple;
my $sforce = WWW::Salesforce::Simple->new(
'username' => $user,
'password' => $pass,
);
the wsdl.jsp file contains the line:
<port binding="tns:SoapBinding" name="Soap">
<soap:address location="https://www.salesforce.com/services/Soap/c/15.0"/>
</port>
This worked fine.
However, what I want to do is connect to the SandBox environment.
I appended ".<our sandbox name>" to the end of the username.
(I was able to login successfully with this username and it's password at https://test.salesforce.com with
a Web browser so I know my credentials are correct).
In the wsdl.jsp file I tried both the above snippet as well as:
<port binding="tns:SoapBinding" name="Soap">
<soap:address location="https://test.salesforce.com/services/Soap/c/15.0"/>
</port>
My Perl script that I am using to try to connect is:
#!/usr/bin/perl -w
use strict;
use WWW::Salesforce::Simple;
my $user = '<the username I successfully used on Web browser with sandbox name appended>';
my $pass = '<our password>';
my $sforce = WWW::Salesforce::Simple->new(
'username' => $user,
'password' => $pass,
);
print "done\n";
When I run this script I get the following error:
INVALID_LOGIN: Invalid username or password or locked out. at ./connect.pl line 10
Not sure how to resolve this. Any assistance with this would be greatly appreciated.
Regards,
RanS
bkus got it right. The $SF_PROXY inside of Salesforce.pm need to be set to the "test" URL to connect to the Sandbox.
So withouth modifying the Salesforce.pm file itself my resulting connection Perl code looks like this:
my $my_serverurl = 'https://test.salesforce.com/services/Soap/u/8.0';
my $user = '<my url>.<my sandbox name>';
my $pass = '<my password>';
my $sforce = WWW::Salesforce::Simple->login(
'username' => $user,
'password' => $pass,
'serverurl' => $my_serverurl
);
That's it. It works. You can set a flag to determine whether to go to "test" (sandbox) or "www" (production) instance.
Cheers and thanks for the help!
All Answers
Edit: Your secuirty token in the sandbox is probably out of date if you have changed it in your production environment since building your sandbox.
let's say my username was hello.world@someplace.com and my sandbox name is "test1"
I successfully logged on to our Sandbox via Web browser using hello.world@someplace.com.test1 as a username using the same password as for the production site.
I did not append anything to my password when attempting this connection via API.
I'll look into resetting password and updating security token.
Okay...so I reset the security token. Sounded like exactly what I was missing.
Let's say my login name is "hello.world@someplace.com.test1"
and my password is "password" and security token is now, let's say, "ABCDE".
My script looks as follows:
use strict;
use WWW::Salesforce::Simple;
my $user = 'hello.world@someplace.com.test1';
#premium support password + security token
my $pass = 'passwordABCDE';
my $sforce = WWW::Salesforce::Simple->new(
'username' => $user,
'password' => $pass,
);
print "done\n";
When running this script I still get:
INVALID_LOGIN: Invalid username or password or locked out. at ./connect.pl line 11
done
Hi Pawel999, what did you do to get it to work?
R
No, it doesn't works :(
I am possibly to much tired. I've put the login/password data valid for production account.
Anyway I've got now the SOAPExeption saying: Fatal error: SoapClient::__setSoapHeaders() [<a href='soapclient.--setsoapheaders'>soapclient.--setsoapheaders</a>]: Invalid SOAP header in /home/xform/temp/temp/soapclient/SforceBaseClient.php on line 274
I'll try to connect to SF using SOAPClient class, then I'll let you know.
Pawel
Function __getLastRequest gives the answer similar to that:
<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:enterprise.soap.sforce.com"><SOAP-ENV:Body><ns1:login><ns1:username>mylogin_mysandbox</ns1:username><ns1:password>mypassword_mytoken</ns1:password></ns1:login></SOAP-ENV:Body></SOAP-ENV:Envelope> " ns1:INVALID_LOGIN
So it is formatted well. Possibly sanboxes have a limited functionality, which excludes logins from Perl/PHP scripts. Pawel
downloading the wsdl.jsp again didn't help. Did you make any changes to it at all ( from www.salesforce.com to test.salesforce.com )?
Did you use SOAP to make it work? I am still attempting to use the perl script I had mentioned above :-(
Any help appreciated...
I had the same issue, but I got it working by modifying my Salesforce.pm file to change the url to the sandbox:
$SF_PROXY = 'https://test.salesforce.com/services/Soap/u/6.0';
Note that I am using a slightly older version of salesforce.pm (0.081) because I had to hack it up in other ways, but I think the newer versions should work the same.
Ben
bkus got it right. The $SF_PROXY inside of Salesforce.pm need to be set to the "test" URL to connect to the Sandbox.
So withouth modifying the Salesforce.pm file itself my resulting connection Perl code looks like this:
my $my_serverurl = 'https://test.salesforce.com/services/Soap/u/8.0';
my $user = '<my url>.<my sandbox name>';
my $pass = '<my password>';
my $sforce = WWW::Salesforce::Simple->login(
'username' => $user,
'password' => $pass,
'serverurl' => $my_serverurl
);
That's it. It works. You can set a flag to determine whether to go to "test" (sandbox) or "www" (production) instance.
Cheers and thanks for the help!