Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

WEB API service fails with 3g/4g but fine with WIFI.

$
0
0

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


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>