Legacy Dev Forum Posts

 View Only

Sign Up

[NEW FEATURE] WithHttpInfo methods in 0.21.1.68

  • 1.  [NEW FEATURE] WithHttpInfo methods in 0.21.1.68

    Posted 06-05-2025 18:10

    tim.smith | 2017-01-23 15:19:17 UTC | #1

    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()); }


    vrvoice1 | 2016-08-10 07:08:01 UTC | #2

    Hi Tim, this is realy interesting to get the correlation ID out of the box. But I don't find it in the C# Api. Is there something similar like that?

    Configuration.getDefaultApiClient().setShouldThrowErrors(false); System.out.println("getCorrelationId: " + userSearchResponseData.getCorrelationId());

    Regards,

    Sven


    tim.smith | 2016-08-10 18:03:29 UTC | #3

    The .NET SDK does have WithHttpInfo methods for API calls, but the ApiResponse class doesn't offer as much functionality. I know that RestSharp doesn't offer as much information as the Java Apache HTTP libraries, but I do have a task to see how close I can get feature parity for the ApiResponse class.


    skansakar | 2016-08-31 09:44:37 UTC | #4

    @tim.smith should all request return a ApiResponse? (e.g. there is no response for patchConversationIdParticipantsParticipantIdWithHttpInfo() on ConversationAPI)


    anon28066628 | 2016-11-29 19:55:25 UTC | #5

    tim.smith, post:1, topic:275
    UsersApi.GetMe() and now UsersApi.GetMeWithApiInfo()

    That should be GetMeWithHttpInfo, right? :slight_smile:

    Can we get HTTP response headers with the Python SDK too, btw?


    tim.smith | 2016-11-30 16:21:12 UTC | #6

    That should be GetMeWithHttpInfo, right? :slight_smile:

    Yea, bad copypasta. :)

    Can we get HTTP response headers with the Python SDK too, btw?

    I've created API-2119 to enhance the Python SDK with additional info for the response.


    anon28066628 | 2016-11-30 17:32:13 UTC | #7

    Thank you Tim, I appreciate it!


    system | 2017-08-28 19:26:18 UTC | #8


    This post was migrated from the old Developer Forum.

    ref: 275