await client.GetAsync(URL) throws no response.

DeepakRamesh.4741DeepakRamesh.4741 USMember ✭✭
edited August 2017 in Cross Platform with Xamarin

Please help me, how to rectify this issue, in normal console application it works, but when i use Xamarin its throws no response. code snippet mentioned below,

static async Task<string> DownloadPage(string username)
    {
        try
        {
            var client = new HttpClient();
            string url =("http://192.168.16.194:90/DomainApi/api/PresentationAnonymousUser/GetUserByUserName?name=" + username);
             HttpResponseMessage response = await client.GetAsync(new Uri(url));
            string result = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
            return result;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

Answers

  • JohnHJohnH GBMember ✭✭✭✭✭

    @DeepakRamesh.4741
    Are you running this on iOS or Droid, on simulator/emulator or physical device, and can you use the web browser on that device to browse to that ip address? My guess is not...

  • prashantvcprashantvc USXamarin Team Xamurai

    Could you post the full stacktrace from the exception? I believe the WebAPIs are hosted on your local server, we may not get same result running it on our test machines

  • JesusAntonJesusAnton USMember ✭✭
    edited August 2017

    recomiendo usar esto

              public async Task<T> GetAsyncObj(string ruta)
                {
                    var httpClient = new HttpClient();
    
                    var json = await httpClient.GetStringAsync(WebServiceUrl + ruta);
    
                    var taskModels = JsonConvert.DeserializeObject<T>(json);
    
                    return taskModels;
                }
    
Sign In or Register to comment.