I am using HttpBuilder-NG. On error I am getting following response from server.
{
"error": "JsonError",
"param": {
"obj.instructorId": [
{
"msg": "Instructor Not Found",
"args": []
}
]
}
}
But HttpBuilder is losing body. The fromServer object is coming as....
fromServer = {JavaHttpBuilder$Action$JavaFromServer@3109}
is = null
hasBody = false
headers = {Collections$UnmodifiableRandomAccessList@3113} size = 10
uri = "**********"
this$1 = {JavaHttpBuilder$Action@3092}
Code for the error handling is
config.getRequest().getHeaders().put("Authorization","Bearer " + AccessToken);
config.getRequest().getUri().setPath(path);
config.getRequest().setBody(paramValues);
config.getResponse().when(400,(fromServer, o) -> {
LazyMap lazyMap = new LazyMap();
lazyMap.put("error", fromServer.getMessage());
return lazyMap;
});