Legacy Dev Forum Posts

 View Only

Sign Up

Exceptions when request should go through a proxy

  • 1.  Exceptions when request should go through a proxy

    Posted 06-05-2025 18:07

    ssteiner | 2023-10-05 16:22:43 UTC | #1

    I just noted that by default, the .NET SDK is made to use no proxy (unfortunately RestSharp seems different in that respect than HttpClient). If you make a request in an environment that needs a proxy, instead of getting a useful error back, you get a` System.ArgumentException: 'Value cannot be null. (Parameter 'source')'` bubbling up from AuthExtensions.CallTokenApi from this call

    apiClient.Configuration.Logger.Trace(method.ToString(), url, postBody, statusCode, headerParams, response.Headers.Select(header => new { Name = header.GetType().GetProperty("Name").GetValue(header), Value = header.GetType().GetProperty("Value").GetValue(header) })
                            .ToDictionary(header => header.Name.ToString(), header => header.Value.ToString()));

    if response.Headers is empty, you get the exception.

    May I humbly request this (and the two subsequent logging lines that have the same issue) be rewritten to handle the case where response has no headers?

    if I skip the logging code, I get a much more useful exception:

    PureCloudPlatform.Client.V2.Client.ApiException: 'Error calling PostToken: The proxy tunnel request to proxy 'http://myproxy.com:8080/' failed with status code '407'."'

    Now that's a lot more useful, no?


    Hemanth | 2023-10-05 16:43:12 UTC | #2

    Hi @ssteiner

    Did you try with latest versions of .NET sdk. That logging problem you mentioned is addressed already.

    Best Regards Hemanth


    ssteiner | 2023-10-05 16:48:45 UTC | #3

    ahh, I thought I had already updated the Nuget package - when I got the exception I went back to the source I downloaded with the first nuget.. and turns out I had never updated the Nuget package from 189 to 190. I see that it's indeed addressed when I look at the code in the Github repo.


    system | 2023-11-05 16:49:22 UTC | #4

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 22386