Im trying to connect to an API and get the data from the "User" table so that the credentials can be authenticated. However after executing GetAsync() the app stucks in a deadlock and doesnt do anything. I have tested the API with postman and it works.
public async Task<User> UserCredentialsGet(string name, string password)
{
var user = new User();
HttpClient client = new HttpClient();
string url = "https://xxx.xxx.xxx.xxx:xxxx/api/Users/username=" + name + "/" + "password=" + password ;
Uri uri = new Uri(url);
try
{
var response = await client.GetAsync(uri).ConfigureAwait(false);
if (response.IsSuccessStatusCode)
{
string content = response.Content.ReadAsStringAsync().Result;
user = JsonConvert.DeserializeObject<User>(content);
}
}
catch (Exception ex)
{
}
return user;
//return await Task.FromResult(user);
}