Hi,
I am developing Xamarin.Forms (PCL) application and I have created separate PCL to consume Web API using HttpClient.
I am able to consume Web API through WIFI but not able to consume with 3g/4g.
Below is sample code.
HttpClient client;
async public Task<List> GetPatientAsync()
{
client = new HttpClient();
client.MaxResponseContentBufferSize = 256000;
List<Patient> responseData;
var uri = new Uri(Constants.PatientUrl);
try
{
var response = await client.GetAsync(uri.AbsoluteUri);
if (response.IsSuccessStatusCode)
{
var jsonString = await response.Content.ReadAsStringAsync();
responseData = JsonConvert.DeserializeObject<List<Patient>>(jsonString);
}
else
{
responseData = new List<Patient>();
}
}
catch (Exception ex)
{
responseData = new List<Patient>();
}
return responseData;
}
Please help.
Thanks