As of v0.21.1.68, all resources now have an additional method with the name ending in WithHttpInfo. For example, there is UsersApi.GetMe()
and now UsersApi.GetMeWithApiInfo()
has been added. These methods return ApiResponse<T>
, where T is the response payload object. The ApiResponse object provides access to the raw body and headers for both the request and response as well as some helper getters to get the HTTP response code, request URI, and correlation ID.
Another feature has also been added to optionally suppress all thrown exceptions from API calls. The default behavior is still to throw exceptions. If you suppress exception when using the standard methods (without HTTP info), the response will simply be null if there was some exception. When using the WithHttpInfo methods, the ApiResponse object will make the Exception object available via ApiResponse.getException()
.
Enough words. Here's some code, also available as a full project on github:
ApiResponse<UsersSearchResponse> userSearchResponseData = usersApi.postSearchWithHttpInfo(searchRequest);
System.out.println("\nRequest elements");
System.out.println("----------------");
System.out.println("getRequestUri: " + userSearchResponseData.getRequestUri());
System.out.println("getRawRequestBody: " + userSearchResponseData.getRawRequestBody());
System.out.println("getRequestHeaderData: " + userSearchResponseData.getRequestHeaderData());
System.out.println("\nResponse elements");
System.out.println("-----------------");
System.out.println("getException: " + userSearchResponseData.getException());
System.out.println("getResponseCode: " + userSearchResponseData.getResponseCode());
System.out.println("getRawResponseBody: " + userSearchResponseData.getRawResponseBody());
System.out.println("getResponseHeaderData: " + userSearchResponseData.getResponseHeaderData());
System.out.println("getCorrelationId: " + userSearchResponseData.getCorrelationId());
System.out.println("\nManual header parsing");
System.out.println("-----------------------");
for (Header h : userSearchResponseData.getResponseHeaders()) {
System.out.println(" " + h.getName() + ": " + h.getValue());
}