0

In my Xamarin.Forms project i am trying to use HttpClient of Windows.Web.Http. I have to use that because i need to ignore some SSL errors. When i create a HttpClient object and try to call a method i get this error message:

Error CS0012 The type 'IAsyncOperationWithProgress<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Windows.Foundation.FoundationContract, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'.

I ve done some research and tried everything i found but couldnt fix it. How can i fix this ? Any help would be appreciated.

Tartar
  • 5,149
  • 16
  • 63
  • 104

1 Answers1

1

In my Xamarin.Forms project i am trying to use HttpClient of Windows.Web.Http. I have to use that because i need to ignore some SSL errors. When i create a HttpClient object and try to call a method i get this error message.

You're using the Windows.Web.Http namespace is platform specific. The underlying implementation relies on the WindowsRT platform. Thus it is not cross-platform.

We recommend use System.Net.Http HttpClient module to make REST API calls in the Xamarin.Forms application. For more you could refer to Using HttpClient with Xamarin.Forms.

  • Install the package Microsoft.Net.Http from Nuget -> For making REST API calls
  • Install the package Newtonsoft.Json from Nuget -> For Serialization/Deserialization of objects.

Usage

HttpClient client = new HttpClient();
var res = await client.GetAsync("http://localhost:5000/api/todo/items");
Nico Zhu
  • 32,367
  • 2
  • 15
  • 36
  • Okay, i am well awared of that and i tried System.Net.Http too but in this case ignoring self-signed certificate errors is a problem. – Tartar Aug 04 '17 at 07:31
  • Yep, you'd better create a new thread for ignoring self-signed certificate errors. – Nico Zhu Aug 04 '17 at 07:35
  • I have been searching for this for last 3 days but still couldnt find any proper solution. I would be appreciated if you can provide a solution. – Tartar Aug 04 '17 at 07:36
  • Please see this thread of mine https://stackoverflow.com/questions/45481509/xamarin-forms-https-and-self-signed-certificate-issue/45481814#45481814. Thanks. – Tartar Aug 04 '17 at 07:47
  • Yep. I am seeing ! – Nico Zhu Aug 04 '17 at 07:49