I'm trying to connect to to Openstack KeyStone from my android project. Basically I'm trying to connect to it by the api openstack has given. PHP format is.
curl -k -X 'POST' -v ####//############/##/### -d '{"auth":{"passwordCredentials":{"username": "joecool", "password":"coolword"}, "tenantId":"5"}}' -H 'Content-type: application/json'
Now i'm trying to integrate this on java on android' But I've been stuck on this for past few days. PHP can perfectly connect. I'm not sure what's wrong with my code in java. Anyone, please give me an idea how to solve this. Thanks! This is my code:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("####//############/##/###");
try {
JSONObject auth = new JSONObject();
JSONObject json = new JSONObject();
auth.put("auth", json);
JSONObject pCredentials = new JSONObject();
json.put("passwordCredentials:", pCredentials);
pCredentials.put("username", "admin");
pCredentials.put("password", "admin");
Log.i("TAG", "passing your data"+auth.toString());
StringEntity params1 = new StringEntity(auth.toJSONString());
params1.setContentEncoding("UTF-8");
params1.setContentType("application/json");
httppost.setHeader("Content-type", "application/json");
((HttpResponse) httppost).setEntity((params1));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
Log.i("TAG", "Server response is "+response.toString());
}catch (IOException e) {
Log.e("TAG", "IOException" + e.toString());
// TODO Auto-generated catch block
}
Are you missing TenantID in the Java code?