Reputation: 1577
I followed a tutorial to send a access token request to Salesforce. But I don't know how to get the response. My code below:
String baseUrl = "https://login.salesforce.com/services/oauth2/token";
PostMethod method = new PostMethod(baseUrl);
HttpMethodParams params = new HttpMethodParams();
StringBuilder content = new StringBuilder();
content.append("grant_type=password");
content.append("&client_id=3MVG9Y6d_Btp4xp7iNInduj8sD72efFl1ge.T8VS9JGJGrWqlNQt2mdP5qFzUdIay56PHFWSO65aFnYLhpTS_");
content.append("&client_secret=4522939082487299040");
content.append("&[email protected]");
content.append("&password=vuong92dnKk2VykEJnVfj5Dps0as9XmRFV");
method.setRequestEntity(new StringRequestEntity(content.toString(), "text/plain", "UTF-8"));
method.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
HttpClient client = new HttpClient();
client.executeMethod(method);
Please help.
Upvotes: 2
Views: 167
Reputation: 97381
After executing
client.executeMethod(method);
you can get the response from the PostMethod
object that you passed as an argument, for example:
String response = method.getResponseBodyAsString();
Documentation can be found here.
Upvotes: 1