Reputation: 11
The vertx implementation of calling / invoking / consuming the REST APIs through requestAbs method of io.vertx.core.http.HttpClient class from vertx-core-3.2.0.jar results in HTTP Error :: 302 and Response Data as HTML Erro Response .
Not sure how the requestAbs method behaves as there's no exception thrown and it does not write any logs as well. Also source code attached for this method with vertx jars. Suspect, if the method implementation has a bug?
The same REST API calls are success with Browser / POSTMAN. The traditional approach with Apache HTTPClient for REST Calls are success, then I doubt why not with vertx framework. Any solution / modification in code snippet below is much appreciated.
Thanks
Upvotes: 1
Views: 2331
Reputation: 860
Your code is a bit confusing (it looks like variables names are not always the same).
Anyway, you will manage to do what you want with that code:
final HttpClient httpClient = vertx.createHttpClient();
final String url = "http://services.groupkt.com/country/get/iso2code/IN";
httpClient.getAbs(url, response -> {
if (response.statusCode() != 200) {
System.err.println("fail");
} else {
response.bodyHandler(b -> System.out.println(b.toString()));
}
}).end();
Hope this will help.
Upvotes: 3