S
Instead doing it literally strings as provided in documentation
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType,
"{\n
\"clientcode\":\"CLIENT_ID\",\n
\"password\":\"CLIENT_PIN\"\n
\"totp\":\"TOTP_CODE\"\n
}"
);
put it in map to reduce chances of error in json format
// Create a Map to represent the JSON structure
Map<String, String> requestBodyMap = new HashMap<>();
requestBodyMap.put("clientcode", "CLIENT_ID");
requestBodyMap.put("password", "CLIENT_PIN");
requestBodyMap.put("totp", "TOTP_CODE");
// Convert the Map to JSON
ObjectMapper objectMapper = new ObjectMapper();
byte[] requestBodyBytes = objectMapper.writeValueAsBytes(requestBodyMap);
// Create the request body
RequestBody body = RequestBody.create(mediaType, requestBodyBytes);