• Umur Ak 10
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
Hello everyone, I am new to salesforce and barely know half of it's cool features!

I am having this strange problem with my company's sandbox org.

I ran through the basic REST-API example code in JAVA, simple OAuth and everything, just to see if I am able to connect to the sandbox using the REST API.

It appears to be that the login failed and showed me the error code 400. 

However, on my personal org, that I can set up after signgin up with an developer-account, the same code appears to work JUST fine. I get no error messages at all, I can even run some basic queries on that.

NOTE: I have configured the JAVA-Code for the REST-API example to the sandbox environment, it's basically like this:
* Login credentials have been replaced with ' * '.
 
public class sbRest {

    private static final String USERNAME     = "*****************";
    private static final String PASSWORD     = "*****************";
    private static final String LOGINURL     = "https://test.salesforce.com";
    private static final String GRANTSERVICE = "/services/oauth2/token?grant_type=password";
    private static final String CLIENTID     = "********************";
    private static final String CLIENTSECRET = "*******************";
    
    
    public static void main(String[]args) throws UnsupportedEncodingException {

        HttpClient httpclient = HttpClientBuilder.create().build();
 
        // Assemble the login request URL
        String loginURL = LOGINURL +
                          GRANTSERVICE +
                          "&client_id=" + CLIENTID +
                          "&client_secret=" + CLIENTSECRET +
                          "&username=" + USERNAME +
                          "&password=" + PASSWORD;
 
        // Login requests must be POSTs
        HttpPost httpPost = new HttpPost(loginURL);
        HttpResponse response = null;
 
        try {
            // Execute the login POST request
            response = httpclient.execute(httpPost);
        } catch (ClientProtocolException cpException) {
            cpException.printStackTrace();
        } catch (IOException ioException) {
            ioException.printStackTrace();
        }
 
        // verify response is HTTP OK
        final int statusCode = response.getStatusLine().getStatusCode();
        if (statusCode != HttpStatus.SC_OK) {
            System.out.println("Error authenticating to Force.com: "+statusCode);
            // Error is in EntityUtils.toString(response.getEntity())
            return;
        }
 
        String getResult = null;
        try {
            getResult = EntityUtils.toString(response.getEntity());
        } catch (IOException ioException) {
            ioException.printStackTrace();
        }
        JSONObject jsonObject = null;
        String loginAccessToken = null;
        String loginInstanceUrl = null;
        try {
            jsonObject = (JSONObject) new JSONTokener(getResult).nextValue();
            loginAccessToken = jsonObject.getString("access_token");
            loginInstanceUrl = jsonObject.getString("instance_url");
        } catch (JSONException jsonException) {
            jsonException.printStackTrace();
        }
        System.out.println(response.getStatusLine());
        System.out.println("Successful login");
        System.out.println("  instance URL: "+loginInstanceUrl);
        System.out.println("  access token/session ID: "+loginAccessToken);
 
        // release connection
        httpPost.releaseConnection();    
    } 
}



Is there any additional configuration I need to make, or any changes on the "network access" on the sandbox platform? I really don't know what could be causing this issue, as for my own personal org, it works just fine, using the exact same code.

I would appreciate any help!

Thank you.
Hello everyone, I am new to salesforce and barely know half of it's cool features!

I am having this strange problem with my company's sandbox org.

I ran through the basic REST-API example code in JAVA, simple OAuth and everything, just to see if I am able to connect to the sandbox using the REST API.

It appears to be that the login failed and showed me the error code 400. 

However, on my personal org, that I can set up after signgin up with an developer-account, the same code appears to work JUST fine. I get no error messages at all, I can even run some basic queries on that.

NOTE: I have configured the JAVA-Code for the REST-API example to the sandbox environment, it's basically like this:
* Login credentials have been replaced with ' * '.
public class sbRest {

    private static final String USERNAME     = "************";
    private static final String PASSWORD     = "************";
    private static final String LOGINURL     = "https://test.salesforce.com";
    private static final String GRANTSERVICE = "/services/oauth2/token?grant_type=password";
    private static final String CLIENTID     = "*********************";
    private static final String CLIENTSECRET = "*****************";
    
    
    public static void main(String[]args) throws UnsupportedEncodingException {

        HttpClient httpclient = HttpClientBuilder.create().build();
 
        // Assemble the login request URL
        String loginURL = LOGINURL +
                          GRANTSERVICE +
                          "&client_id=" + CLIENTID +
                          "&client_secret=" + CLIENTSECRET +
                          "&username=" + USERNAME +
                          "&password=" + PASSWORD;
 
        // Login requests must be POSTs
        HttpPost httpPost = new HttpPost(loginURL);
        HttpResponse response = null;
 
        try {
            // Execute the login POST request
            response = httpclient.execute(httpPost);
        } catch (ClientProtocolException cpException) {
            cpException.printStackTrace();
        } catch (IOException ioException) {
            ioException.printStackTrace();
        }
 
        // verify response is HTTP OK
        final int statusCode = response.getStatusLine().getStatusCode();
        if (statusCode != HttpStatus.SC_OK) {
            System.out.println("Error authenticating to Force.com: "+statusCode);
            // Error is in EntityUtils.toString(response.getEntity())
            return;
        }
 
        String getResult = null;
        try {
            getResult = EntityUtils.toString(response.getEntity());
        } catch (IOException ioException) {
            ioException.printStackTrace();
        }
        JSONObject jsonObject = null;
        String loginAccessToken = null;
        String loginInstanceUrl = null;
        try {
            jsonObject = (JSONObject) new JSONTokener(getResult).nextValue();
            loginAccessToken = jsonObject.getString("access_token");
            loginInstanceUrl = jsonObject.getString("instance_url");
        } catch (JSONException jsonException) {
            jsonException.printStackTrace();
        }
        System.out.println(response.getStatusLine());
        System.out.println("Successful login");
        System.out.println("  instance URL: "+loginInstanceUrl);
        System.out.println("  access token/session ID: "+loginAccessToken);
 
        // release connection
        httpPost.releaseConnection();    
    } 
}

Is there any additional configuration I need to make, or any changes on the "network access" on the sandbox platform? I really don't know what could be causing this issue, as for my own personal org, it works just fine, using the exact same code.

I would appreciate any help!

Thank you.
 
Dear developers,

I am new to salesforces, and I am just getting to know the whole platform, so please be gentle with me.

I am currently working on a new project, it's basically a time-tracking application, and it needs to be interacting with the data from my salesforce org.
The time-tracker is a stand-alone JAVA application, displaying information, editing information, retrieving, updating, logins etc., should be happening on the application-side. The org will be more like a database for the time-tracker.

As far as I know, and correct me if I'm wrong, there are multiple API's available on salesforce. I am going to be honest with you, I am overwhelmed by the descriptions of these API's, and I can't seem to figure out which one would fit the use-case of my project.

Can anyone help me out on this? What API should I be using? Is there any tutorial out there that shows exactly what I want? I am developing in Netbeans by the way.

Any help or advise will be much appreciated.

Thank you.
Hello everyone, I am new to salesforce and barely know half of it's cool features!

I am having this strange problem with my company's sandbox org.

I ran through the basic REST-API example code in JAVA, simple OAuth and everything, just to see if I am able to connect to the sandbox using the REST API.

It appears to be that the login failed and showed me the error code 400. 

However, on my personal org, that I can set up after signgin up with an developer-account, the same code appears to work JUST fine. I get no error messages at all, I can even run some basic queries on that.

NOTE: I have configured the JAVA-Code for the REST-API example to the sandbox environment, it's basically like this:
* Login credentials have been replaced with ' * '.
 
public class sbRest {

    private static final String USERNAME     = "*****************";
    private static final String PASSWORD     = "*****************";
    private static final String LOGINURL     = "https://test.salesforce.com";
    private static final String GRANTSERVICE = "/services/oauth2/token?grant_type=password";
    private static final String CLIENTID     = "********************";
    private static final String CLIENTSECRET = "*******************";
    
    
    public static void main(String[]args) throws UnsupportedEncodingException {

        HttpClient httpclient = HttpClientBuilder.create().build();
 
        // Assemble the login request URL
        String loginURL = LOGINURL +
                          GRANTSERVICE +
                          "&client_id=" + CLIENTID +
                          "&client_secret=" + CLIENTSECRET +
                          "&username=" + USERNAME +
                          "&password=" + PASSWORD;
 
        // Login requests must be POSTs
        HttpPost httpPost = new HttpPost(loginURL);
        HttpResponse response = null;
 
        try {
            // Execute the login POST request
            response = httpclient.execute(httpPost);
        } catch (ClientProtocolException cpException) {
            cpException.printStackTrace();
        } catch (IOException ioException) {
            ioException.printStackTrace();
        }
 
        // verify response is HTTP OK
        final int statusCode = response.getStatusLine().getStatusCode();
        if (statusCode != HttpStatus.SC_OK) {
            System.out.println("Error authenticating to Force.com: "+statusCode);
            // Error is in EntityUtils.toString(response.getEntity())
            return;
        }
 
        String getResult = null;
        try {
            getResult = EntityUtils.toString(response.getEntity());
        } catch (IOException ioException) {
            ioException.printStackTrace();
        }
        JSONObject jsonObject = null;
        String loginAccessToken = null;
        String loginInstanceUrl = null;
        try {
            jsonObject = (JSONObject) new JSONTokener(getResult).nextValue();
            loginAccessToken = jsonObject.getString("access_token");
            loginInstanceUrl = jsonObject.getString("instance_url");
        } catch (JSONException jsonException) {
            jsonException.printStackTrace();
        }
        System.out.println(response.getStatusLine());
        System.out.println("Successful login");
        System.out.println("  instance URL: "+loginInstanceUrl);
        System.out.println("  access token/session ID: "+loginAccessToken);
 
        // release connection
        httpPost.releaseConnection();    
    } 
}



Is there any additional configuration I need to make, or any changes on the "network access" on the sandbox platform? I really don't know what could be causing this issue, as for my own personal org, it works just fine, using the exact same code.

I would appreciate any help!

Thank you.
Dear developers,

I am new to salesforces, and I am just getting to know the whole platform, so please be gentle with me.

I am currently working on a new project, it's basically a time-tracking application, and it needs to be interacting with the data from my salesforce org.
The time-tracker is a stand-alone JAVA application, displaying information, editing information, retrieving, updating, logins etc., should be happening on the application-side. The org will be more like a database for the time-tracker.

As far as I know, and correct me if I'm wrong, there are multiple API's available on salesforce. I am going to be honest with you, I am overwhelmed by the descriptions of these API's, and I can't seem to figure out which one would fit the use-case of my project.

Can anyone help me out on this? What API should I be using? Is there any tutorial out there that shows exactly what I want? I am developing in Netbeans by the way.

Any help or advise will be much appreciated.

Thank you.