Actually I am using REST API call for deleting studies and series(for our viewer program in java) for which I am trying to access token. When I tried the curl command for accessing token, that worked fine.
But when trying to access token using java application, I am getting HTTP error code : 400.
String name = "admin";
String password = "admin";
String authString = name + ":" + password;
URL url = new URL(urlString);
HttpURLConnection conn1 = (HttpURLConnection) url.openConnection();
conn1.setDoOutput(true);
conn1.setRequestProperty("Authorization", "Basic " + authString);
conn1.setRequestProperty("grant_type", "password");
conn1.setRequestProperty("client_id", "dcm4chee-arc-ui");
conn1.setRequestProperty("Content-Type", "application/json");
conn1.setRequestMethod("POST");
if (conn1.getResponseCode() != 200)
{
throw new RuntimeException("Failed to access token: HTTP error code : "
+ conn1.getResponseCode());
}
InputStream is = conn1.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
This is the java segment I am using to get the token. I am getting http error code 400. Could you please help me with this? Do I need to add any more parameters?