http://unirest.io/java.html
You have to use body method as per the documentation.
Example
Unirest.setTimeouts(7000, 7000);
HttpResponse<JsonNode> accessToken = Unirest.post("https://api4.truecaller.com/v1/apps/requests")
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.header("appKey", "app-key-here")
.header("Cache-Control", "no-cache")
.body("{\"phoneNumber\":7777777777}")
.asJson();
OR
Unirest.setObjectMapper(new ObjectMapper() {
private com.fasterxml.jackson.databind.ObjectMapper jacksonObjectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
public <T> T readValue(String value, Class<T> valueType) {
try {
return jacksonObjectMapper.readValue(value, valueType);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public String writeValue(Object value) {
try {
return jacksonObjectMapper.writeValueAsString(value);
} catch (com.fasterxml.jackson.core.JsonProcessingException e) {
throw new RuntimeException(e);
}
}
});
class Test implements Serializable {
final public Long phoneNumber;
public Test(Long phoneNumber) {
this.phoneNumber = phoneNumber;
}
}
Test t = new Test(7777777777L);
Unirest.setTimeouts(7000, 7000);
HttpResponse<JsonNode> accessToken = Unirest.post("https://api4.truecaller.com/v1/apps/requests")
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.header("appKey", "app-key-here")
.header("Cache-Control", "no-cache")
.body(t)
.asJson();