Use API created in C# to fetch data from SQL database and use it across iOS,android apps in Xamarin

PallaviAgPallaviAg USMember
edited August 2014 in Visual Studio

Hello ,
I am using Visual Studio for Xamarin to create android and iOS app. I have SQL database from which I want fetch or modify data through android and iOS apps. I went through the cross platform documentation to avoid the duplicate efforts. I saw that we can use SQLite database but we don't want go with that approach. Basically we want create our own service which will be published at our server and
use that service in native user interface. But I am not sure which API to create and how to use that. I have created Web API (Rest) in .NET framework. Which has three methods can I use that API in native apps and how to use that. How to call a method ?I have researched a lot but didn't find any thing. Many of the examples are for Eclipse IDE in Java but I want create this kind if app in xamarin for Visual studio where I am not able to create Java class. Any help would be highly appreciated. Please guide me if I am using the wrong process or if there is any other approach to create such app in xamarin for Visual Studio.



  • JonDouglasJonDouglas USXamarin Team, University, Developer Group Leader Xamurai

    Hey @PallaviAg‌

    You can go ahead and create a REST API from your database in which you can then consume in a cross platform fashion via HttpClient.

    Here's a great blog about getting HttpClient added to your project:

  • PallaviAgPallaviAg USMember

    Thanks Jon,
    I have created Web API(rest) which has three methods. But I am not sure how to use that API in android and call a method and display the sql data on android.

  • PallaviAgPallaviAg USMember

    Hello Jon, I have added the reference for Newtonsoft.json in my rest api,
    Added a Generic handler.
    DBConnect.cs connects to SQL database..
    IServiceAPI.Cs contains the method defination.
    ServiceAPI contains the method declaration.
    Handler1.ashx.cs contains handler.

    Please guide me how to use this API across multiple platform using Xamarin for Visual Studio.

  • PareshSukhiyaPareshSukhiya USMember ✭✭

    @PallaviAg Can You Share your Code
    as I am new to this field and i want to learn more about the SQL and Xamarin Android!
    Help from your side will be highly appreciated!

  • RajenSharma9900RajenSharma9900 INMember ✭✭

    I am not able to add System.Net.Http to my PCL of cross platefrom xamarin app. I am using Visual studio community 2017 on windows 7. When i access SQL database table Employee is display data with web application. But when i connect with android emulator or device is doesn't display data. Please give a solution to use xamarin forms cross platform application with Microsoft sql server access using web services(web api) on versions of windows & visual studio and email me ot [email protected]

  • hi i am a beginner i want to create a log In and sign up app and save data in user account can you guys help me how to get started and what is the best method to save date online

Sign In or Register to comment.