Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

What is the best way to make HttpWebRequests to an existing Api in xamarin.forms

I am developing an app for users to get information about store promotions/sales. There is already an existing API with all the relevant methods needed for the app functionality. I have minimal experience with WebApi's so will just appreciate advice/guidelines on the best approach to make HttpWebRequests to this existing Api using xamarin.forms. Thanks :)


  • Gigex42Gigex42 USMember ✭✭✭✭

    Im using this:

    using (HttpClient client = new HttpClient())
    using (HttpResponseMessage response = await client.PostAsync(reqstring, cont))
    if (response.StatusCode != System.Net.HttpStatusCode.OK)
    return null;
                        using (HttpContent content = response.Content)
                            string result = await content.ReadAsStringAsync();
                            var Settings = JsonConvert.DeserializeObject(result);
                            return Settings;

    reqstring is you requeststring and cont can be your parameter passing to the service.

    But seeing this post there sems to be a problem with the httpclient within a using statement.

Sign In or Register to comment.