TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Veeresh Kumar
NA
51
14.1k
Fatch Data from local Host Api in Xamarin Forms
Nov 29 2018 7:30 AM
This is my Code and i Can't fatch data from api in xamarin.
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
public static List<data> getPersons()
{
List<data> lp = new List<data>();
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
try
{
HttpResponseMessage response = client.GetAsync("http://localhost:51949/api/employee").Result;
if (response.IsSuccessStatusCode)
{
lp = JsonConvert.DeserializeObject<data[]>(response.Content.ReadAsStringAsync().Result).ToList();
}
}
catch
{
}
return lp;
}
private async void Button_Clicked(object sender, EventArgs e)
{
var list = getPersons();
await Navigation.PushAsync(new ListOfEmployee());
}
}
Reply
Answers (
2
)
Xamarin Forms Binding Source Question
Xamarin android passing and reset time between activities