0

I am using the same code mentioned in https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/code_sample_auth_oauth.htm It works fine in Chrome extension POSTMAN. I am passing the same POST parameters that is used in POSTMAN in my java code. Any help is appreciated.

I am getting 500 error with below response

An internal server error has occurred

An internal server error has occurred An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.

Thank you again for your patience and assistance. And thanks for using salesforce.com! An internal server error has occurred An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.

Thank you again for your patience and assistance. And thanks for using salesforce.com!

Error ID: 1328242241-114053 (801801977)

public static void oAuthSessionProvider(String loginHost, String username, String password, String clientId, String secret)
        throws HttpException, IOException
{
    // Set up an HTTP client that makes a connection to REST API.
    DefaultHttpClient client = new DefaultHttpClient();
    HttpParams params = client.getParams();
    HttpClientParams.setCookiePolicy(params, CookiePolicy.RFC_2109);
    params.setParameter(HttpConnectionParams.CONNECTION_TIMEOUT, 30000);

    // Set the SID.
    System.out.println("Logging in as " + username + " in environment " + loginHost);
    String baseUrl = loginHost + "/services/oauth2/token";
    // Send a post request to the OAuth URL.
    HttpPost oauthPost = new HttpPost(baseUrl);
    // The request body must contain these 5 values.
    List<BasicNameValuePair> parametersBody = new ArrayList<BasicNameValuePair>();
    parametersBody.add(new BasicNameValuePair("grant_type", "password"));
    parametersBody.add(new BasicNameValuePair("username", username));
    parametersBody.add(new BasicNameValuePair("password", password));
    parametersBody.add(new BasicNameValuePair("client_id", clientId));
    parametersBody.add(new BasicNameValuePair("client_secret", secret));
    oauthPost.setEntity(new UrlEncodedFormEntity(parametersBody, HTTP.UTF_8));

    // Execute the request.
    System.out.println("POST " + baseUrl + "...\n");
    HttpResponse response = client.execute(oauthPost);
    int code = response.getStatusLine().getStatusCode();
    System.out.println(code);
    System.out.println(response.getStatusLine().getStatusCode());
    String theString = IOUtils.toString((
            new InputStreamReader(response.getEntity().getContent())));
    System.out.println("response-->"+theString);
}
  • Follow the instructions. Only Salesforce can assist you. – crmprogdev Mar 8 '17 at 14:45
  • Please share your JAVA code. – Saroj Bera Mar 8 '17 at 14:53
  • Just added the java code to the question. – Raja Vivekanandhan Mar 8 '17 at 14:58
1

Hi Thank you everyone for your help. I was able to resolve the issue by upgrading to Java 8. The underlying cause was that, salesforce discontinued support for TLS1.0. Java 7 by default is not TLS1.1/1.2 but Java 8 is. The 500 error misguides the user. This is something Salesforce need to update with correct error message. The error message appears correctly when testing web-server authorization.

I found the solution accidentally while trying to implement the "web-server" authorization method . Salesforce was responding with 400 error message TLS 1.1 or higher required and I solved that by upgrading java.

0

Hope this helps for people who are trying to connect from .Net platform to SFDC.

As of now Salesforce supports only TLS 1.2 for integration(Which might get updated with the new version in the future, its always better to share the TLS version details with API details to Consumers.)

As Raja Vivekanandan explained above, same issues happened with .Net application. But if .Net application is trying to connect with Salesforce, No need of any up gradation. Just add the below line of code in C# before accessing the endpoint url.

ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.