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
CharanCharan 

Java with force.com REST API

Team,

 

Did any one come across this link.

http://wiki.developerforce.com/index.php/Getting_Started_with_the_Force.com_REST_API

 

 

1)When I click to Run On Server, it is redirecting to http://localhost:8081 page.

I have configures https on my Tomcat Server.

 

I want to OFF http sever. How can I make it?

 

2)When i try to execute this, Html file executes and Salesforce link as provided in the HTMl page appears, but when I click on that link it is not redirecting me to Salesforce login page.

 

I am getting 404 error.

 

 

Kindly help me out with your suggestions.

 

 

 

Regards,

Charan 

Pat PattersonPat Patterson

Hi Charan,

 

1) Presumably you have already configured Tomcat for SSL. You should be able to turn off the non-SSL connector by commenting it out in server.xml, like this:

 

<!--
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
-->

 

 

2) Check your Remote Access app configuration, particularly the redirect URI, and restart your browser (or remove all salesforce.com cookies) before you test. On clicking the link, you should see the Salesforce login screen, then the authorization screen (if you have not already authorized your app) then the demo app. If this is not happening, then check that the redirect URI has the correct path to the demo app on Tomcat - e.g. https://localhost:8443/RestTest/oauth/_callback

 

Please post any follow up here as you will get the fastest response here, not via email.

 

Cheers,


Pat

cha runcha run

Patterson, thanks for your reply.

 

 

Regards,

 

Charan

 

 

 

Pat PattersonPat Patterson

All working now?

 

By the way - you can call me 'Pat' :-)

 

Cheers,

 

Pat

CharanCharan

Pat,

 

 

I am still stucked up...

 

 

When I clcik on the Link in HTML page I am redirected to Salesforce login page.

 

Firstly, I authorized once. When I clicked on Approve, it is again redirecting to HTML page..

 

 

No action is taking place.

 

 

Help me.

 

 

 

Regards

 

 

Charan

charan@appscharan@apps

Pat,

 

 

I am a bit confused about Callback URL.

 

 

I tried again with the same code in the Force.com blog.

 

 

I am successfully redirected to Login screen of Salesforce.com and whene I click on Login(Already Approved the App) it shows up with an error.

 

 

RestTest/oauth/_callback  not available. Getting code in the URL.

 

A bit confused about this. can you please explain.

 

 

 

 

Cheers,

 

Charan

Pat PattersonPat Patterson

Hi Charan,

 

It sounds like you've deployed the sample app to a different context path - the sample code uses /RestTest. If you deployed to a different context path you will need to change the redirect URI from https://localhost:8443/RestTest/oauth/_callback to match whatever you used.

 

Cheers,

 

Pat

emacadieemacadie

I think the sample app really only works with JEE 6. Right now I need to use JEE 5. I guess JEE 5 cannot handle the string "_callback" at the end of the URL.

 

So I made a copy of the servlet that I called OAuth2, and I set the callback URL to that. I still use OAuthServlet for the first authentication.

 

charan@appscharan@apps

Emacadie,

 

thanks for your reply.

 

 

I think you rsolution may solve my problem.

 

i have to give a try. I am working on JEE5.

 

 

I didnt understand the way you are doing for JEE5.

 

 

 

 

 

regards

 

Charan

charan@appscharan@apps

Yuppie!!!!!

 

 

I got it finally after taking JavaEE 6.0.

 

 

Thanks emacadie and Pat for your support.

 

 

Need to Explore  more.

 

 

 

Million hugs to you both.

 

 

Cheers!!

 

 

Charan

R2KR2K

Pat,

It seems that I have a similar problem, also even more strange as initally I managed to get past the authentication. However, now, I cannot get the DemoREST servlet to run properly.

...
INFO: Server startup in 2243 ms
Auth successful - got callback
May 24, 2011 1:46:10 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
May 24, 2011 1:46:10 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
May 24, 2011 1:46:31 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
May 24, 2011 1:46:31 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
May 24, 2011 1:46:54 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
May 24, 2011 1:46:54 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
java.net.ConnectException: Connection timed out: connect
 at java.net.PlainSocketImpl.socketConnect(Native Method)
 ...

Apparently I do no longer get a access token back when running the example scenario. The DemoREST servlet terminates with "Error - no access token" after I get properly forwarded via https://na7.salesforce.com/setup/secur/RemoteAccessAuthorizationPage.apexp?source=l86Hcy...

I don't know if this i related to the fact that I already had authorized my app yesterday evening?! Still, I do not understand why I cannot receive an access token anymore, and that consequently the application crashes.

By the way, I have a related question: with the Firefox Add-On Poster I tried to re-create the HTTP Post call to https://login.salesforce.com/services/oauth2/token with the parameters that are given in the sample code, extended with a code that I can receive from the authentication, I receive the following XML back

<?xml version="1.0" encoding="UTF-8"?><OAuth><error>unsupported_grant_type</error><error_description>grant type not supported</error_description></OAuth>

Unsupported grant type? for "authorization_code"?

I probably should have split the message, sorry...

Thanks and kind regards,
Reto

Pat PattersonPat Patterson

Hi Reto,

I haven't seen this kind of timeout before. It is possible to enable logging with the Apache HTTP client - you could try that and see if it gives any clues - http://hc.apache.org/httpclient-legacy/logging.html

On the 'unsupported_grant_type' error - this is often due to a bad encoding in the body of the form post - e.g. sending grant_type%3Dauthorization_code%26... instead of grant_type=authorization_code&...

Cheers,

Pat