0

I'm trying to get data from a webservice using json, on another project i did it with WebClient class but that project was a Shared project, this particular project is a Portable Class Library project so webclient is not available, i know in this case i have to use httpclient class, but i'm failing to make it work.

this is the code from the working shared project, i need the same to work in a portable class library project.

*NOTE that in this particular case i don't need any parameters to be sent.

string obtainParkingData(string email)
        {
            WebClient client = new WebClient();
            Uri uri = new Uri("http://mydomain/mywebservice.php");
            NameValueCollection params = new NameValueCollection();
            params.Add("p_email", email);

            byte[] responseBytes = cliente.UploadValues(uri, "POST", params);
            string responseString = Encoding.UTF8.GetString(responseBytes);
            return responseString;
}
  • 1
    Check this other answer, it might help https://stackoverflow.com/questions/33020657/how-to-replace-webclient-with-httpclient – DHLopez Oct 02 '17 at 20:18
  • https://developer.xamarin.com/guides/xamarin-forms/cloud-services/consuming/rest/ – Jason Oct 02 '17 at 21:11

0 Answers0