Hey,
I'm working on a java application that gets documents from the content server. The issue here is that when I generate the auth token from postman using the following API and pass it to the respective call as OTCSTicket, I'm getting the appropriate response, it works just fine.
https://{url}/otcs/cs.exe/api/v1/auth
However, when I try to do the same using the token generated from the java code. I get 401 unauthorized. the java code :
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("username",username)
.addFormDataPart("password",password)
.build();
Request request = new Request.Builder()
.url("https://{url}/otcs/cs.exe/api/v1/auth")
.method("POST", body)
.build();
try {
Response response = client.newCall(request).execute();
String token = response.body().string();
System.out.println(token);
int index = token.indexOf(":");
String finalToken = token.substring(index+2,token.length()-2);
return finalToken;
}
token :{"ticket":"XyUQm7Y4uunfcWm99\/5gyg0tef15Ij+P5lYIVop2JB5vTOATc6fdqx45HtQdUKzbAagYBnKn7hyAgliGnuRz8q1ajM9kcydPIhph5YbPYyz6Mpfc95Gd6oUcJl\/iegQiLcDAMlcUQgs="}
finalToken : XyUQm7Y4uunfcWm99\/5gyg0tef15Ij+P5lYIVop2JB5vTOATc6fdqx45HtQdUKzbAagYBnKn7hyAgliGnuRz8q1ajM9kcydPIhph5YbPYyz6Mpfc95Gd6oUcJl\/iegQiLcDAMlcUQgs=