wadewegner/Force.com-Toolkit-for-NET

Calls after defining proxy not working

Opened this issue · 1 comments

Hello,
I am trying to define a proxy used when I call Salesforce.
To do that, I create an HttpHandler that I pass to my ForceClient constructor.
Here is the code I use:

var htttpClientHandler = new System.Net.Http.HttpClientHandler
                {
                    Proxy = new
System.Net.WebProxy(string.Format("{0}:{1}", proxyAddress, proxyPort))
                };

htttpClientHandler.UseDefaultCredentials = true;

var httpClient = new System.Net.Http.HttpClient(htttpClientHandler);

 client = new ForceClient(instanceUrl, accessToken,apiVersion, httpClient, httpClient);

Using that, every time I make a salesforce call, I get a parsing error like this:
Unexpected character encountered while parsing value: <. Path ", line 0, position 0."

Here is the stack trace:

à Newtonsoft.Json.JsonTextReader.ParseValue()
   à Newtonsoft.Json.JsonTextReader.Read()
   à Newtonsoft.Json.Linq.JToken.ReadFrom(JsonReader reader,
JsonLoadSettings settings)
   à Newtonsoft.Json.Linq.JToken.Parse(String json, JsonLoadSettings settings)
   à Newtonsoft.Json.Linq.JToken.Parse(String json)
   à Salesforce.Common.JsonHttpClient.<HttpGetAsync>d__4`1.MoveNext()
   à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
   à System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   à Salesforce.Common.JsonHttpClient.<HttpGetAsync>d__3`1.MoveNext()
   à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
   à System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   à CMASalesforce.Business.Services.SalesforceService.<getQueueId>d__58.MoveNext()

Did I miss something in my configuration?
Thank you

Hello,
I m getting the same error when i try to create an AuthenticationClient (so prior to create the ForceClient).
Here is the code :

	var htttpClientHandler = new System.Net.Http.HttpClientHandler
	{
		Proxy = new System.Net.WebProxy(address, bypassOnLocal, bypassList)	
	};

	htttpClientHandler.UseProxy = true;
	htttpClientHandler.UseDefaultCredentials = true;
	htttpClientHandler.DefaultProxyCredentials = CredentialCache.DefaultCredentials;

	var httpClient = new System.Net.Http.HttpClient(htttpClientHandler);

	var auth = new AuthenticationClient(httpClient, apiVersion);
	await auth.UsernamePasswordAsync(clientId, clientSecret, username, password, endpoint);

Here is the error and stack trace :

JsonReaderException : Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

image