function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TuringTuring 

Unable to access UAT Sandbox via API - Connected Apps

Hi All,

We have been using our UAT Sandbox environment to access salesforce objects on our custom websites  via Salesforce API's. 

we can successfully validate the conenction using the credentials ( of API user) and passing the cosumer and secret of our connected app, which went through succesfully by giving us the Token, but when we try to access the salesforce objects using the generated token, it failed and gave us error message 'Connection Failure'.

While the same code is working fine with Production environment.

The issue with the UAT - Sandbox started all of the suddent, one day it was working fine and next day we started enperiencing this issue.

Any help will be highly appreciated.

Thanks
Numan
pconpcon
When you try to connect to your UAT Sandbox, you are using the instance url that is returned by the authentication process and not your production environments instance url?  Also, do you have any additional messages other than "Connection Failure"
TuringTuring
Thanks pcon.
We are using test.salesforce.com and the strange thing is it was working fine untill Monday 18th of May. We are getting Token back after validating with the test.salesforce.com. but it failed wehn we try to access sobjects.
TuringTuring

We are not getting detailed error message. only 'Conenction Failure.' and i have also check the login history of the integration user and every time we try to connect it shows  Connection successfull for our Connected App (Application) via Remote Access 2.0(Login Type) , login url(test.salesforce.com). 

pconpcon
After you do the initial login request, what url are you using to send your subsequent object requests?
TuringTuring
Accessing Salesforce Object using https://cs8.salesforce.com/services/data/v30.0/sobjects/Contact/describe
pconpcon
Did you happen to refresh your UAT sandbox or did that sandbox move to a host that is not cs8?  Are you pulling the uri from the login request?
TuringTuring
yes we did recently refreshed our sandbox, and the sand box is still on the same host cs8. not getting your second question
pconpcon
Ok.  The second question refers to after you make the login request part of the resultant payload includes your sessionId and a serverUrl.  This serverUrl contains which instance you are running on and you should be using it instead of hardcoding in any sort of endpoint.

Can you provide a cURL or an example request that you are making? (With the session id redacted of course)
TuringTuring
ok got it. This is runtime generated server instance url https://cs8.salesforce.com 
TuringTuring
insUrl = generated at runtime which is (cs8.salesforce.com)
"#insUrl#/services/data/v30.0/sobjects/...
TuringTuring
<cfhttp url="#insUrl#/services/data/v30.0/sobjects/Contact/describe" method="get" result="catrolapi">
<cfhttpparam type="header" name="Authorization" value="#axTok#">
<cfhttpparam type="header" name="X-PrettyPrint" value="1">
pconpcon
The only thing I can see wrong is that the Authorization header should be "Bearer {{SessionId}}".  I don't know what the value of "#axTok# is.

If I do the following in cURL it works for me.  You can try to output the values of insUrl and axTok and plug them in below to see if you get the same error message
 
curl -X GET -H "X-PrettyPrint: 1" -H "Authorization: Bearer $SFDC_SESSIONID" $SFDC_SERVERURL/data/v30.0/sobjects/Contact/describe

 
TuringTuring
Thanks pcon,

we are outputting the value of token(type bearer) and instanance url to axTok and insUrl variable respectively.

 and also the Authorization variable we are using above which is axTok has format = "Bearer XXXXXXXXXXXXXgenerated tokenXXXXXXXXX"

and we are not gdoing anything different in our test code, the production code is same and working with no errors.

The only thing i am worrying about is, something is broken on Salesforce side on UAT sandox (in our case is CS8).
pconpcon
I don't have any sandboxes on CS8 to confirm.  I would try using a tool like cURL to see if you get the same error.  If you do then you can increase the verbosity and maybe that will give you more information as to why the error is occuring.  Also it will take your application out of the mix and will show if it the Salesforce endpoint or something within your application.
TuringTuring
Thank you pcon. let me try using the cURL. Do you know how we can log ticket with Saleforce.com for Sanbox issues. I know they only handle support tickets for their prime customers.
pconpcon
What they support is based on the type of contract you have with them.  You may or may not have developer support.  If you do have developer support then they should support you with a sandbox issue.  If this is an infrastructure issue, they should support you regardless, but getting them to understand that it is an infrastructure issue and not an issue with your code will be the "tricky" part.
TuringTuring
Exactly you are right. they have denied my first request. i think i need to open another case with them.

Thanks you so much for helping me out.