I want get signle text value from WEB API in xamarin

wenkket 1 Reputation point
2020-11-27T07:05:16.03+00:00

i was tried like below in xamaring forms, pls. help

public class ItemListClass
{
public string Item_Name { get; set; }
public string Price { get; set; }
public string Total { get; set; }
}

public async void saleItems_bind()
{
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(new
System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://xyz.in/api/SaleItems?invNo=1");
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
var ItemsS = JsonConvert.DeserializeObject<List<ItemListClass>>(content);
PItmeList.ItemsSource = ItemsS;

        List<ItemListClass> tabiv = new List<ItemListClass>();
        var details = from x in tabiv select new { name= x.Item_Name.FirstOrDefault(), pric = x.Price.FirstOrDefault() };
        foreach (var k in details)
        {


            lbNam.Text = name.ToString();
            lbPric.Text = pric.ToString();
        }           
    }
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,354 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.