// Call OkHttp
Map<String, Object> data = new HashMap<>();
data.put("appId", "AB00000004");
data.put("appKey", "3d58bcfbf47e05fc593ac2fe0508d213");
Gson gson = new Gson();
RequestBody body = RequestBody.create(gson.toJson(data), MediaType.parse("application/json; charset=utf-8"));
Request request = new Request.Builder()
.url("https://ecom-api.ottpay.com/api/v1/auth/token")
.post(body)
.build();
final OkHttpClient httpClient = new OkHttpClient();
try (Response response = httpClient.newCall(request).execute()) {
if (!response.isSuccessful()){
throw new IOException("Request failed." + response);
}
// Get Response
System.out.println(response.body().string());
} catch (IOException e) {
throw new RuntimeException(e);
}