HttpClient PostAsync Parameter Invalid

I just deployed Windows 10 64-bit Education on my Macbook Air, a slightly updated installer from my main development computer that also runs Windows 10 64-bit Education.

I installed Visual Studio 2017 and downloaded all the nuggets packaged for my design solution just like I did it on my development machine.

My problem is that I am running production code that we use all the time and have not received any complaints from our customers, it is not working on my fresh install / install.

We have a login method with a simple username and password field. When we call the PostAsync method, it submits the form data to our servers. I used Postman and got the correct answer. The code has not been changed or changed at all and is known working code. I also work in a cafe and a home wife, and this is the only difference. I have yet to try this to work in the office. Customers go to cafes and use home Wi-Fi all the time.

Any thoughts and suggestions would be greatly appreciated

Latent exception - but my code hasn't changed at all?

{System.ArgumentException: The parameter is incorrect.
The parameter is incorrect.
at Windows.Web.Http.HttpClient.PostAsync(Uri uri, IHttpContent content)
at CoreProject.Helpers.LogginHelper.<UserLogin>d__1.MoveNext()}

      

EDIT:

URI configuration code

Uri uri = new URI("https://oururi.com/login");

      

HttpClient setup code

// disable caching
// https://social.msdn.microsoft.com/Forums/en-US/79e98534-5d8e-4879-acbe-7a457ee2a7ad/windowswebhttphttpclient-turn-off-caching?forum=winappswithcsharp
var RootFilter = new HttpBaseProtocolFilter();
RootFilter.CacheControl.ReadBehavior = HttpCacheReadBehavior.NoCache;
RootFilter.CacheControl.WriteBehavior = HttpCacheWriteBehavior.NoCache;

HttpClient httpClient = new HttpClient(RootFilter);
httpClient.DefaultRequestHeaders.Add("email", email);
httpClient.DefaultRequestHeaders.Add("pw", password);
httpClient.DefaultRequestHeaders.Add("apiVersion", "2.0");
httpClient.DefaultRequestHeaders.Add("version", CacheHelper.getVersionString());
httpClient.DefaultRequestHeaders.Add("appID", CacheHelper.Config.AppId());
httpClient.DefaultRequestHeaders.Add("platform", "windows");
httpClient.DefaultRequestHeaders.Add("updated", LocalSettingsHelper.GetContentLastUpdatedTimestamp());
httpClient.DefaultRequestHeaders.Add("bundleID", CacheHelper.Config.BundleId());
httpClient.DefaultRequestHeaders.Add("vendorID", Windows.System.UserProfile.AdvertisingManager.AdvertisingId);
httpClient.DefaultRequestHeaders.Add("deviceType", UtilityHelper.DeviceType());
httpClient.DefaultRequestHeaders.Add("osVersion", AnalyticsInfo.VersionInfo.DeviceFamilyVersion);

String termsValue = didAcceptTerms ? "1" : "0";
httpClient.DefaultRequestHeaders.Add("terms", termsValue);
return httpClient;

      

Calling the method that throws the exception

 HttpResponseMessage response = await httpClient.PostAsync(uri, null);

      

+3


source to share





All Articles