I have a WEB API hosted on a server, there I have a Products table with Name and Description.I already checked for the postman and this is ok, when I try to implement the method in xamarin by visual studio to bring a record by its name and display in a listview I can not. Could someone help me in the code
private async void GetProductByName(string Name)
{
using (var client = new HttpClient())
{
txtTest.Text = "http://www.ProdutosAPITest6.hostname.com/api/products";
var URI = txtTest.Text + "/" + Name.ToString();
var response = await client.GetAsync(URI);
string products = await response.Content.ReadAsStringAsync();
var product = JsonConvert.DeserializeObject<Produto>(products);
listview.ItemsSource = products;
}
}
<ListView x:Name="ProductsList" ItemSelected="listaProducts_ItemSelected"
BackgroundColor="Aqua" SeparatorColor="Blue">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="10,10" Orientation="Horizontal">
<Label Text="{Binding Id}" HorizontalOptions="StartAndExpand"/>
<Label Text="{Binding Name}" TextColor="Blue" HorizontalOptions="Center"/>
<Label Text="{Binding Description}" HorizontalOptions="End"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>