Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calls after defining proxy not working #377

Open
Cheelax opened this issue Jun 3, 2020 · 1 comment
Open

Calls after defining proxy not working #377

Cheelax opened this issue Jun 3, 2020 · 1 comment

Comments

@Cheelax
Copy link

Cheelax commented Jun 3, 2020

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

@aimenux
Copy link

aimenux commented Nov 20, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants