Forum General


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.

Connect a REST WebService with Xamarin App

Hey guys,
I´ve finished my REST WebService which is connected to a MySQL database. Now I want to connect this WebService to a Xamarin App, the App should display the data from the database. Yet there are some points that are unclear to me.
1. How to connect the REST WebService with my App, do I need to host in on a cloud like Azure?
2. How to display the data when they are connected?

Hopefully you can help me, I would be really grateful for your help. I am very new to all of this stuff and want to learn how to build cool Apps with Xamarin.
Thanks in advance!


  • AsfendYarAsfendYar USMember ✭✭✭

    Hi @Juventiono1897 !
    Consuming rest api's in xamarin forms is really easy.
    Let me share a video link with you where you can learn to consume the web api's.

    Get Request In Xamarin Forms

    Post Request In Xamarin Forms

    Put Request In Xamarin Forms

    Delete Request In Xamarin Forms

    And I'm sure after watching these four videos Get , Post , Put and Delete you can easily consume the Rest Api's in your Xamarin Forms application.

  • Juventino1897_1Juventino1897_1 Member ✭✭

    Thank you for your help. I will watch the videos.
    If there is still something unclear, may I ask you again?

  • Juventino1897_1Juventino1897_1 Member ✭✭

    @AsfendYar i watched the video an have a question. You hosted your API on Azure right? And is it for free? If not do you know good alternatives which are for free. If it is for free do you have a good tutorial about it where it gets explained how to do it?

  • AsfendYarAsfendYar USMember ✭✭✭

    Well Azure offers a 30 days trial to the new users worth US 200 dollars.
    I don't know much about free hosting stuff. Most probably the only free way is to host the web api on your machine and then use the Visual Studio Extension Conveyor by Keyoti
    And with the help of Conveyor you can consume your api in your device and emulator.

  • Juventino1897_1Juventino1897_1 Member ✭✭
    edited March 2020
    I´ve just seen that firebase is free if you don´t reach some maxima. I think I will try this one.
  • Juventino1897_1Juventino1897_1 Member ✭✭

    @AsfendYar I wanted to try the free Azure trial but there is another problem...I don´t have a credit card :(. Same at AWS. Well I have to look for alternatives.

  • AsfendYarAsfendYar USMember ✭✭✭
    edited March 2020

    Yeah it depends on your choice. Firebase is free but I'm not sure whether .Net support is available in Firebase or not. In which platforms you're making the rest api's ?

  • Juventino1897_1Juventino1897_1 Member ✭✭

    Do you mean on which OS I want to consume the API?

  • soufianemarlysoufianemarly Member ✭✭✭

    hope this will help it work fine for me connection with credential. use RestQharp and newtonsoft.json NuGet

                    var app = Application.Current as App;
                    IRestResponse result_Absence = API(app.Properties["identifiant"].ToString());
                    Console.WriteLine("result_Absence " + result_Absence.Content);
                    var JsonResult = JsonConvert.DeserializeObject<dynamic>(result_Absence.Content);
                    Console.WriteLine("APIAbsence " + JsonResult);
                    string lienyear = JsonConvert.SerializeObject(JsonResult);
                    s = JObject.Parse(lienyear);
                    Console.WriteLine(" Json result " + s);
        public IRestResponse API(string login_ldap_key_value)
            var app = Application.Current as App;
            var client = new RestClient(app.Properties["endPoint"].ToString());
            string login_ldap_key_name = app.Properties["ETUD__LOGIN"].ToString();
            var request = new RestRequest("/isa_student/list_absences/" + app.Properties["theyear"].ToString());
            request.AddParameter("login_ldap_key_name", login_ldap_key_name);
            request.AddParameter("login_ldap_key_value", login_ldap_key_value);
            request.Method = Method.GET;
            var credentialCache = new CredentialCache();
              new Uri(app.Properties["endPoint"].ToString()), // request url's host
              "Digest",  // authentication type 
              new NetworkCredential(app.Properties["endPoint_user"].ToString(), app.Properties["endPoint_pwd"].ToString()) // credentials 
            request.Credentials = credentialCache;
            IRestResponse response = client.Execute(request);
            return response;
Sign In or Register to comment.