Message from Author

Following tutorial is currently not up to date and there are lots of bug in it. Please don’t use this tutorial to any of your production work.

Please click below link to the new tutorial in restful api

Restful API for Android and IOS using ASP.NET Web API 2

Thank you

 

Most of the android applications use an API (Application Programming Interface) for send and receive data from servers to client (App).  API is very useful when application need to show dynamic data to end user. For an instance think how Gmail app receives emails?  It uses an API to communicate with Google mail server. When there is a new email, server notifies the application through API. Flipboard application also uses the same mechanism to update flipboard. When flipboard server database is updated it notifies the app then application download the data through API. This is the basic usage of APIs in android.

In this tutorial I’ll show you how to create a restful API for android  (JSON based API) application using ASP.net and Microsoft SQL Server Database.  You can use MySQL or other databases instead of SQL server. I’ll use SQL server because it is easy to use with ASP.net (Both are Microsoft Products).  I’ll try to make this tutorial simple and clear to understand. If you find any issue please feel free to ask. You can use the comment section to communicate with me.

Demo Video

[quote_box_center]

This tutorial is quite long; to make it simple I divided it to two parts. In this tutorial (Part 1) I’ll cover the Creation of the API using ASP.net and SQL Server.  In Restful API for Android  Part 2 I’ll cover how to implement this API in Android Application.

[/quote_box_center]

Overview Of the tutorial

This tutorial will show you the basic implementation of the restful API. I’ll show you how to connect android application with SQL server through a restful API. In android application users able create a user account and login to the account through the restful API. Application will retrieve department details from SQL Server database and display in a listview.

Step 1: Download Resources

Download and extract the resource files need to implement the restful API from below download button.

Json Services : Download DLL Files [quote_box_center]

I’ll use C# as the primary programming language in Visual Studio 2012.  I will use .NET Framework 4.5 to demonstrate this tutorial. This is also work with .NET Framework 3.5 and .NET Framework 4.

[/quote_box_center]

Step 2: Creating a Project and Initialization

Open Visual Studio and create an “ASP.NET Empty Web Application” project.  Project name is “JSONWebAPI”. Follow below steps to create the project.

  1. Go to “File=>New” Click “Project” or Press “Ctrl+Shift+N”
  2. From the New Project window select  Web category from left panel
  3. Then Select “ASP.NET Empty Web Application” from center panel
  4. Give Name as “JSONWebAPI
  5. Select project “Location” from Browse (Or keep the default)
  6. Make sure “Create directory for solution” is checked
  7. Click “OK” button
Create New Project - Restful API for Android
Create New Project

Now you need to add those “dll” files in “JsonServices (0.3.4) folder in downloaded resource to the .NET Web Application. Follow below steps to add dll file to the project.

  1. Right click on “JSONWebAPI” project in “Solution Explorer
  2. From the menu click on “Add Reference” item  to open the “Reference Manager
  3. Click “Browse” from the left panel
  4. Then click “Browse” button at bottom of “Reference Manager
  5. Then go to the location where you extract the downloaded  Resource Files 
  6. Then select all three “.dll” files and click “Add” button
  7. Then click “OK” button (Make sure to checked all three file)
Add DLL Files as Reference - Restful API for Android
Add DLL Files as Reference

Now you need to add a “Generic Handler” to your “Solution Explore”. Follow below steps.

  1. Go to “PROJECT” menu in Visual Studio 2012 then click “Add New Item” (Ctrl+Shift+A)
  2. From “Add New Item” window select “Web” category from left panel
  3. From center panel select “Generic Handler
  4. Keep the default Name “Handler1.ashx
  5. Then click “Add” button

Now create three classes namely “ServiceAPI.cs”, “IServiceAPI.cs” and “DBConnect.cs”. Follow below steps to create a new class

  1. Go to “PROJECT” menu then click “Add New Item
  2. From left panel select “Code” category
  3. Select “Class” item from center panel
  4. Give the class name as “ServiceAPI.cs
  5. Click “Add” button

Repeat the same instruction to create “IServiceAPI.cs” and “DBConnect.cs class.

Step 3: SQL Server Database Creation and Manipulation

Now we jump from visual studio to SQL server. I’ll not go in-depth about SQL Server. I’ll only show you basic stuff you need to know in order to complete this tutorial. If you are beginner then follow all the instruction carefully.

Firstly open the SQL Server Management Studio and connect to the server. Please keep the server name in your mind. Later you need that Server Name to connect to SQL Server from API. In my case it is “AHAMEDISHAK”

Connect To SQL Server - Restful API for Android
Connect To SQL Server

Press Connect button to connect your Server. Now I’ll do the tutorial part by part.

1. Create a New Database

To create a new database called “AndroidAppDB” follow the below steps

  1. Select “New Database” from right clicking “Database” folder in “Object Explore
  2. In “New Database” window  give the Database Name as “AndroidAppDB
  3. Then click “OK” button to create the database.

2. Create Database Tables

Before create tables create a “New Query” file and select the correct database. In this case “AndroidAppDB”. If you’re a beginner keep this in mind because before doing any updates to a database we need to select database first.  It is very important step you need to follow every time you update the database through a Query file.

Select Correct Database - Restful API for Android
Select Correct Database

Now “Execute” below sql queries to create table. I’ll create two tables.

-------------Table 1: UserDetails (To store user information)---------------

CREATE TABLE UserDetails (
	id INT IDENTITY,
	firstName VARCHAR(50),
	lastName VARCHAR(50),
	userName VARCHAR(50),
	password VARCHAR(50),
);

-------------Table 2: Dept (To store Department information)---------------

CREATE TABLE Dept(

	no INT,
	name VARCHAR(50),

	PRIMARY KEY (no)
);

----------------------Insert data to Dept Table------------------

INSERT INTO Dept VALUES (1,'Accounting');
INSERT INTO Dept VALUES (2,'Marketing');
INSERT INTO Dept VALUES (3,'Information Technology');
INSERT INTO Dept VALUES (4,'Networking');
INSERT INTO Dept VALUES (5,'Management');
INSERT INTO Dept VALUES (6,'Medical');
INSERT INTO Dept VALUES (7,'Electronics');
INSERT INTO Dept VALUES (8,'Finance');
INSERT INTO Dept VALUES (9,'Engineering');
INSERT INTO Dept VALUES (10,'Defense');

Step 4: Connect and Configure the SQL Server Database to JSONWebAPI

Now come back to Visual Studio. Next part of the tutorials is to connect the newly created database to our API project. By doing this we can programmatically retrieve and update information in database. To configure the connection open the “Web.config” file in Solution Explorer. Update your file by adding below configuration lines. Please add below lines between <configuration> and </configuration>


    ConString" connectionString="Data Source=AHAMEDISHAK; Initial Catalog=AndroidAppDB;Integrated Security=True " providerName="System.Data.SqlClient" /&amp;gt;
  

Above configuration code is used to connect SQL Server database in my PC.  So this will not work for your API until you change the “Data Source” value to your “Server Name”. Simply delete the “AHAMEDISHAK” value and use your SQL “Server Name” there. “Catalog” value should be the database name. If you need to connect different database give the correct Database Name there. “ConString” is the name of the “Connection String”.  If you need to connect more than one database at same time you need to create a new “Connection String” with different name and configurations.

Next Open the “DBConnect.cs” class. This class is used to connect with the database. Update your class according to below code.  Don’t forget to add correct header files. Otherwise it will show you errors.

using System.Configuration;
using System.Data.SqlClient;

namespace JSONWebAPI
{
    ///
/// This class is used to connect to sql server database
    ///
    public class DBConnect
    {

        private static SqlConnection NewCon;
        private static string conStr = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;

        public static SqlConnection getConnection()
        {
            NewCon = new SqlConnection(conStr);
            return NewCon;

        }
	    public DBConnect()
	    {

	    }

    }
}

Now connecting and configuration part is over.

Step 5: Let’s Code

Next we need to configure the API interface which is used to handle the communication between android application and API. To configure the API interface open the “Handler1.ashx” file. Delete the example codes given in the file. Update the “Handler1.ashx” according to below code.  Use correct header files in your code.

using JsonServices;
using JsonServices.Web;

namespace JSONWebAPI
{
    public class Handler1 : JsonHandler
    {
       public Handler1()
        {
            this.service.Name = "JSONWebAPI";
            this.service.Description = "JSON API for android appliation";
            InterfaceConfiguration IConfig = new InterfaceConfiguration("RestAPI", typeof(IServiceAPI), typeof(ServiceAPI));
            this.service.Interfaces.Add(IConfig);
        }

    }
}

Now you need to do some small changes to “IServiceAPI.cs” and “ServiceAPI.cs” class. “IServiceAPI.cs” should be an interface instead of a class. To change the “IServiceAPI.cs” to an interface open the file and change the class keyword to interface. Next “ServiceAPI.cs” class should extend the “IServiceAPI.cs” interface.  See below codes to if you didn’t understand.

namespace JSONWebAPI
{
    public interface IServiceAPI
    {

    }
}

 

namespace JSONWebAPI
{
    public class ServiceAPI : IServiceAPI
    {

    }
}
[quote_box_center]

Interface is similar to class file. Main different is we only declare methods in interface. We will not implement any method in interface. Interface is extends by a class. Class which extends the interface should implement all the methods in interface.

[/quote_box_center]

Now open the” IServiceAPI.cs” interface file. Add following method declarations according to below code.

using System.Data;

namespace JSONWebAPI
{
    ///
/// This interface declare the methods need to be implement.
    ///
    public interface IServiceAPI
    {
        void CreateNewAccount(string firstName, string lastName, string userName, string password);
        DataTable GetUserDetails(string userName);
        bool UserAuthentication(string userName, string passsword);
        DataTable GetDepartmentDetails();
    }
}

Next we need to implement declared method in “ServiceAPI.cs”. Open the “ServiceAPI.cs” class. Update the class according to below code. It is important make all methods “public”.

using System;
using System.Data;
using System.Data.SqlClient;

namespace JSONWebAPI
{

    public class ServiceAPI : IServiceAPI
    {
        SqlConnection dbConnection;

        public ServiceAPI()
        {
            dbConnection = DBConnect.getConnection();
        }

        public void CreateNewAccount(string firstName, string lastName, string userName, string password)
        {
            if (dbConnection.State.ToString() == "Closed")
            {
                dbConnection.Open();
            }

            string query = "INSERT INTO UserDetails VALUES ('"+firstName+"','"+lastName+"','"+userName+"','"+password+"');";

            SqlCommand command = new SqlCommand(query, dbConnection);
            command.ExecuteNonQuery();

            dbConnection.Close();
        }

        public DataTable GetUserDetails(string userName)
        {
            DataTable userDetailsTable = new DataTable();
            userDetailsTable.Columns.Add(new DataColumn("firstName",typeof(String)));
            userDetailsTable.Columns.Add(new DataColumn("lastName",typeof(String)));

            if (dbConnection.State.ToString() == "Closed")
            {
                dbConnection.Open();
            }

            string query = "SELECT firstName,lastName FROM UserDetails WHERE userName='"+userName+"';";

            SqlCommand command = new SqlCommand(query, dbConnection);
            SqlDataReader reader = command.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    userDetailsTable.Rows.Add(reader["firstName"], reader["lastName"]);
                }
            }

            reader.Close();
            dbConnection.Close();
            return userDetailsTable;

        }

        public bool UserAuthentication(string userName, string passsword)
        {
            bool auth= false;

            if (dbConnection.State.ToString() == "Closed")
            {
                dbConnection.Open();
            }

            string query = "SELECT id FROM UserDetails WHERE userName='" + userName + "' AND password='" + passsword + "';";

            SqlCommand command = new SqlCommand(query, dbConnection);
            SqlDataReader reader = command.ExecuteReader();

            if (reader.HasRows)
            {
                auth = true;
            }

            reader.Close();
            dbConnection.Close();

            return auth;

        }

        public DataTable GetDepartmentDetails()
        {

            DataTable deptTable = new DataTable();
            deptTable.Columns.Add("no", typeof(String));
            deptTable.Columns.Add("name", typeof(String));

            if (dbConnection.State.ToString() == "Closed")
            {
                dbConnection.Open();
            }

            string query = "SELECT no,name FROM Dept;";
            SqlCommand command = new SqlCommand(query, dbConnection);
            SqlDataReader reader = command.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    deptTable.Rows.Add(reader["no"], reader["name"]);
                }
            }

            reader.Close();
            dbConnection.Close();

            return deptTable;

        }
    }
}

We have completed the restful API in ASP.NET 🙂

Step 6: Run Restful API

In this step you can run the API in a browser. Use the Play (Run) button in menu bar to run the API or go to “DEBUG” menu and click “Start Debugging” or press F5 from the keyboard. At first you will see a web page like below. This is because you are not pointing to the correct page of the API.

Error Page - Restful API for Android

To solve this problem simply add “/Handler1.ashx” to the end of the URL. In my case complete URL is “http://localhost:7541/Handler1.ashx”. “Handler1.ashx” is the handler of the API. If you used any other name for the handler in your API use that name instead of “Handler1”.Then you will see below webpage

API Main Page - Restful API for Android
API Main Page

As you can see in the output you can use this restful API with different technologies. But I’ll only cover how to use this in android environment. To use this restful API with Android you need to download the client interface file from Server. To do that enter “?ANDROID” to end of the URL in browser. In my case URL is “http://localhost:7541/Handler1.ashx?ANDROID”. Then it will pop up a “Save As” dialog box to save the file in your PC. Change the file name to “APIClient.zip”.

Save the Client Interface
Save the Client Interface

Step 7: Restful API for Android Part 2  tutorial

In Restful API for Android Part 2 tutorial I’ll show you how to use this restful API in a client android application. Subscribe to the website through your email or our social media pages in Google Plus, Facebook, Feed Burner and YouTube to get instant notification about new tutorials and videos.  See the video demonstration of the tutorial how to do this tutorial from start to end. You can download the source code of this tutorial below. If you have any questions related to this tutorial feel free to ask. Comment section is open for you to communicate with me.

Share this tutorial with your friends and give a support to my website. Thank you very much for visiting TuteCentral.

Video Demonstration

Downloads

Download Sample Code

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

  • Tudor

    Great Tutorial! When do you think part two will be ready? I am trying it on my own but am having some issues. Do I basically import the RestAPI.java file into my Android project and call the methods within it? Or do I need to do this using the HttpClient in Android? Thanks again!

    • Ahamed Ishak

      I’m working on it.. I’ll publish the part 2 probably next week. I can’t tell specific date because I have tight schedules these days. To use this Import the RestAPI.java into your project. Then open the RestAPI.java and point the urlString to Handler1.ashx (http://localhost:7541/Handler1.ashx?). Then you need to call the methods inside AsyncTask Class.

    • Dimitris Klimis

      @disqus_D3NquWoHNM:disqus, I didn’t read the details, but as far as I know, this is a ‘web service’. What this means is that this will exist locally on your server and will be able to connect, query your DB, create a JSON representation of your DB data and finally return this to whomever asked.

      Then, from any remote point, you can query by calling the web service through normal internet protocols. So, you would say https://www.my.app/service.aspx?bar=foo and that will connect to that .aspx file, query the DB and return a JSON file (instead of an html you would normally get from a web server).

      From that remote point, you can parse the JSON file and present the data as needed. So I don’t think you need to import anything. If you want to test it, have 2 devices in the same network and on your ‘server’ create a web server including this .aspx file and from the ‘client’, go to a web browser and just access the address of your web server. That should return a JSON file.

      @ahamedishak:disqus, correct me if I’m wrong. Thanks for your guide. Take care.

  • Niwemwiza Amatullah Ashley

    Hey Mr Ahamed,
    Really you saved my life by providing this mechanisme, I had a final Project of University for android, but I was stack a whole month because of missing these concepts. God bless you.
    Allow me to contact you (privately)….
    God bless you Sir!

    • Ahamed Ishak

      Thank you.. Share this with your friends and colleagues.. Give a support.. God Bless You…

      • Niwemwiza Amatullah Ashley

        Sir I have a Question, your Database contains some integer values, but I didn’t see any declaration of Integer in API and Java code for Android.
        Because I am implimenting your example but I think this would cause a problem parsing values.

        Suggest me sir Thank you!

        • Ahamed Ishak

          Yes Database has some integer value.. It is not a problem when we retrieve values from database.Because API client will return a JSONObject Type of object for each request. So you can retrieve an Integer type object from JSONObject. There are inbuilt methods in JSONObject to do that task for you. So you simply call that method to retrieve an integer value. Check the PART2 of this tutorial I have a JSONParser class which will convert a JOSNObject to a some other type of object. You can create your own parsing methods according to your class and DB.

          When you try to insert a value through the API. It will convert the JAVA integer to JSONObject then It will convert that JSONObject to ASP.net Integer. That part will handle by the API by it self so you no need to worry about that.

          I hope this explanation may solve your doubts. If not no worries ask any question..

          Thank you
          God bless you.. .

          • Niwemwiza Amatullah Ashley

            This explanation was good enough, and I understood 100%. API is important tool.
            I am now learning how to implement those staffs is not easy.

  • Adam Hunchak

    Do you have examples with authenticating API calls for once you have logged in through the web service? Also your method of logging in, is it just sending the password to the web service in clear text? What would you have to do to use SSL?

    • Ahamed Ishak

      Sorry to tell I don’t know how to use this with SSL but you can send the password after encrypt using some encryption mechanism..

  • ASAD FAROOQ

    hi, i am using your method but when android application try to connect database it shows following error and select nothing from database.
    kindly solve my problem i have less time to complete my project…… and thanks for this beautiful TUTORIAL

    • Ahamed Ishak

      There should be some problems with your queries. Recheck it.

  • oguz

    Hi Ahamed,
    how can i save image sql server image type,
    i try byte[] type but no succes

    • Ahamed Ishak

      Store the Image URL in the website then retrieve it using api.

      • oguz

        I pick image android gallery and i d like to save sql server,
        but Android generator byte[] type in c# for java
        Arraylist doesnt use java,
        Java arraylist only Arraylist use

      • oguz

        Service response {“ErrorMessage”:”Internal server error”,”Successful”:false},
        I send ArrayList data return this response,
        web service method parameter byte[],
        where do mistake ?

    • oguz

      how to save image sql for your method,
      firstly i pick image galerry and convert image bytearray byte[],
      i send myservice there is no result

    • oguz

      Hi Ahamed,
      I solve problem another method,
      I post base64 string after decode image,
      thanks for your interested!

    • Şeyhmus Gümüş

      merhaba oğuz kendi url mi kullanırken internal server error hatası alıyorum bunun sebebini çözdunmu bana yardım edersn çok sevnrm

      • oguz

        Web servisine image i base64 tipinde encode ederek gönderiyorsun veritabanında da varchar olarak tutabilirsin image verileri

      • oguz

        İmage göndermeyi soyluyorsan söylediğim şekilde

      • oguz

        Web servisine image i base64 tipinde encode ederek gönderiyorsun veritabanında da varchar olarak tutabilirsin image verileri

      • oguz

        İnternal hatasi da sanirim gönderdiğin veri tipi web servisindekiyle uyuşmuyor bence primitive tipler kullanmayi dene bir de servisi calistir hangi dil de client kodu yazacaksan onun kodlarini kendi olustuyor zaten ondaki kodlari kullan eğer kod oluşturma da hata aliyorsan veri tiplerini tekrar gözden geçir derim

        • Şeyhmus Gümüş

          yok ben image gondermiyorum bana facdene yazarmısn ya
          https://www.facebook.com/gumus4747
          birde veri tiplerinde sıkıntı yok

        • Şeyhmus Gümüş

          beni faceden eklermisn kardeş ya

          https://www.facebook.com/gumus4747

          • oguz

            Buradan yazabilirim hatanin çözümü gönderdiğin parametrelerle alakalı diye düşünüyorum servise gönderdiğin parametreler de sikinti oluyor veya eslesmiyor debug yap kesinlikle önce basit bir hello world metodun olsun ondan sonra o metodu cagirmayi dene kolaydan zora doğru git

          • oguz

            Metodlarina sadece string göndererek dene öncelik olarak ve mutlaka bak servisi calistirdiginda client kodunu olustuyor mu olusturmuyorsa başka hatalar var demektir

          • Şeyhmus Gümüş

            gönderdiğim parametrelerde nasıl bir sıkıntı olabilirki
            http://seyhmusgumus.com/Handler1.ashx
            buda servis urlm

          • oguz

            Client kodunu kastediyorum debug yap hangi dilde client yaziyorsun servisinde sikinti yok gibi

          • Şeyhmus Gümüş

            android java yazıyorum kodda bir sorun bulmadım ben debug yapıyorum

          • Şeyhmus Gümüş

            gamilden veya başka yerden konuşalımmı çok az zamnım var problemi çözüp projeyi bitirmeme lazım

          • Şeyhmus Gümüş

            birde servisi Test Ettğimde boyyle bir hata alıyorum

            405 Method Not Allowed

            Method Not Allowed
            The HTTP verb used to access this page is not allowed.

            Web Server at seyhmusgumus.com

            <!–
            – Unfortunately, Microsoft has added a clever new
            – "feature" to Internet Explorer. If the text of
            – an error's message is "too small", specifically
            – less than 512 bytes, Internet Explorer returns
            – its own error message. You can turn that off,
            – but it's pretty tricky to find switch called
            – "smart error messages". That means, of course,
            – that short error messages are censored by default.
            – IIS always returns error messages that are long
            – enough to make Internet Explorer happy. The
            – workaround is pretty simple: pad the error
            – message with a big comment like this to push it
            – over the five hundred and twelve bytes minimum.

          • oguz

            O hatayi stackoverflow da bak tam bilmiyorum ama hatanin nedeni web config dosyasinda olabilir sitenin desteklemediği veya kabul etmediği birşeyler olabilir

          • Şeyhmus Gümüş

            baktım bişi bulamadım bu adamın yaptığının aynısını yaptım adamn çalşıyor bnmki çalşmyor

          • oguz

            Senin sitenin ayarlari ile de alakali olabilir hata olmasa bile sitenin bazi ayarlari eksik olabilir web config dosyanda birşeyler yapman gerekebilir

          • Şeyhmus Gümüş

            tmm teşekür ederm

  • Ahamed Ishak

    You are using the part of the url full url should be this http://android.somee.com/Handler1.ashx

    • ASAD FAROOQ

      i use http://android.somee.com/Handler1.ashx the whole url plz tell me where i m doing mistake

      • Ahamed Ishak

        There is a Null pointer exception in your program.. Please try to find and solve it…. using Log.d() try to check in which line error is occuring.. Or debug your program..

        • ASAD FAROOQ

          When i set your path in “RestAPI” like this “private final String urlString =”http://tutecentral.somee.com/Handler1.ashx”;” and run app in emulator and print the String Named “result” in this function “private String load(String contents) throws IOException” in the “RestAPI.java” class then it give following and much more resultened values

          {“Successful”:true,”value”:[{………………},

          but when i set my URL in “RestAPI” like this
          “private final String urlString =”http://android.somee.com/Handler1.ashx”;” and print the string “result” then it show like this and select no value

          {“Successful”:false,”ErrorMessage”:”Internal server error”},

          • ASAD FAROOQ

            sir kindly help me i have very short time to complete my project and i have to do big work of my project in MSSQL server DB…….

          • ASAD FAROOQ

            sir i’m waiting for your response!…

          • Ahamed Ishak

            Hi sorry for delay.. It because there is a problem in your api.. Please check the methods in the api. Method is not successfully executing. Debug your api to find the method. Add a debug pointer in your api code and then call the method through your emulator then it will stop at your debug point. Use F10 to execute it line by line to fine the error.

          • ASAD FAROOQ

            but when i give your address in android app it works probably.

          • Şeyhmus Gümüş

            hello ı have { “Successful”: false, “ErrorMessage”: “Internal server error” }.

            this error how to fixed this ?

  • Raquel De Faria Oliveira

    Hi. When I run the project: http://localhost:7541/handler1.ashx?help, I see the message: { “Successful”: false, “ErrorMessage”: “Internal server error” }. I did download and change the webConfig. When I run the project whitout Help show the page such as tutorial.

    • Ahamed Ishak

      why are you using ?help at end of the URL

  • Raquel De Faria Oliveira

    When I import Part2 and I run occurs error. Then I did test with ?help to test and I think Part1 have error.

  • Raquel De Faria Oliveira

    I explain better.
    1) I run Part1 in Visual Studio 2012
    2) In browser, I write: http://localhost:7541/handler1.ashx
    3) Show the dialog box. (the same tutorial)
    4) If I write: http://localhost:7541/handler1.ashx?help, I see the message: { “Successful”: false, “ErrorMessage”: “Internal server error” }.
    5) Then, I import Part2 in Eclipse
    6) I change in RestAPI, urlString to: “http://10.0.2.2/JSONWebAPI/Handler1.ashx”;
    7) When I run, show the menu
    8) But when I click in Department Details, nothing happen
    9) If I don’t change the urlString, the department list is showed.

    Thank you

    • Şeyhmus Gümüş

      hello ı have { “Successful”: false, “ErrorMessage”: “Internal server error” }.
      this error how to fixed this please help me

      • Can u plz explain how u solve this. After hosting on server.

    • mohiuddin shamim

      Did u slove this problem ?? I am getting the same error as yourself..{ “Successful”: false, “ErrorMessage”: “Internal server error” }.

  • Adnan

    Hello Ahamed, first of all thank you for this great example, i’ve been looking an example about this subject. İ did everything but what i need to know is how do i check if api is working or not ?is there a way to use it via querying browser in pc and show json output from database ? I’m just an amateur programmer and trying to learn.

  • Ridmi Jayasena

    Hey Ahamed, I am new to Android, and I’m stuck in this for couple of days now 🙁 I try to do an app very much similar to yours. I followed all steps that you explained in both the tutorials. But when I finally try to run the application it doesn’t produce any output. It prompt a message saying “Your app unfortunately has stopped” I can’t figure out what I did wrong. Please help me with this

    • Ahamed Ishak

      By looking your comment even I can’t figure out the problem 🙂 . To find the the issue you can check the logcat of the application. All the trace information will be there.

  • Hajar Hardi

    Hi, Can I use Visual Studio 2010 for this ?

    • Ahamed Ishak

      Yes.. You can use VS2010

      • Hajar Hardi

        Thank you 🙂 I have an other question
        when i run the asp project i get this url in my browser : http://localhost:13237/Handler1.ashx is this what i should use as urlString in RestAPI.java?

        • Ahamed Ishak

          check the second tutorial I have mention it detaily. you need to use http://10.0.2.2:13237/Handler1.ashx in RestApI.java

          • Hajar Hardi

            Thank you for your quick answers, i tried this still not working for me
            In eclipse log I get : failed to connect to /10.0.2.2 (port 13237)

          • Ahamed Ishak

            did you follow my second tutorial. In there I have mention all the steps you need to follow in order to use this api. What is the Emulator you use?

          • Hajar Hardi

            yes i followed it,
            i run directly on my phone

          • Guest

            “then you can’t access it using a real android device “

          • Ahamed Ishak

            You cannot access the localhost through your mobile phone.. there is no network connection between your phone and pc. so you need to host the api in the public hosting space in order to access it through the phone. Check the second tutorial I have mention there how to access the api through phone.

          • Hajar Hardi

            i didn’t follow the part about how to run on android emulator i’ll try this now
            Thank you again

  • Guest

    Hi, I have a question , when i run the asp project i get this URL “http://localhost:13237/Handler1.ashx” is this what i should use for urlString in RestAPI.java ?

  • fatinz

    hello ı was project on host ı work this on tutorial but ı can not on localhost ı watch localhost tutorial but can not project can ı help you for localhost please but ı working real device

    • Ahamed Ishak

      Sorry to tell I could not understand your problem..

  • fatinz

    hello ı write this project normal write on visual stuido and ı ımport folder to server but do n t work but ı doıng your project copy paste and send files to server your project working but ı write myself same project same with codes do not working ı getting sometimes NO VALUE FOR err
    or. anad sometimes ı do not have this error

  • Zineb Chams

    Please can i work with visual studio 2008 and sql server 2008 ?

    • Ahamed Ishak

      It should work. But I never used it with VS2008. You can use SQL Server 2008.

  • Khaled Yabroudi

    Dept Activity doesn’t return any value !! my webservice working well and every thing as u write ?!

  • Brett

    I keep getting this error while trying to check if the api is working. Anyone have any ideas.

    Line 1:

  • Kushan Dilranga Wickramasinghe

    Dear Sir, i am a complete new bee to this web-service process. I just want to know whether i am able to use this tutorial to connect to an online hosted mssql database and retrieve data to my android application. What are changes needed to be done to this code. Your help is largely appreciated.
    Thanks & Regards,
    Dilranga

    • Ahamed Ishak

      Yes. You can send and retrieve data using this API. Changes are depend on your requirements.

  • Guest

    My database there’s Sql server Authentication to input login/password. Do I have to change something in web.config?

    thanks

  • Gok lok

    My database there’s Sql server Authentication to input login/password. Do I have to change something in web.config?

    thanls

    • Guest

      like this?

  • Zineb Chams

    I want to know if I can create a Web service part independent from the published Web site? that means that I want to create a project which contains three parts : Client part, web service part and server part.

  • Atiqur Rahman

    Pretty awesome tutorial for sure, works fine for me – both on IIS and web host. But I guess it is necessary to secure the web service, please make another post describing how to authorize the web service.

  • Thushara

    Any insight about where did you get the jsonservices.dll and jsonservices.web.dll . Any reference ?

    • Ahamed Ishak

      There was a Google open source project but owner removed it now. I don’t know why. I uploaded these DLLs into my server after he removed the project.

      • Thushara

        Ela machan… Thanks… I found out his project… It is no longer there though.. It is a simple but impressive library .. too bad he abandoned it 🙂

  • richard

    Hi Ahamed Ishak , can you help me how to insert image in sql database

    • Ahamed Ishak

      There are several ways to store image in SQL. Use can use BLOB type in MySQL or image type in SQL server. You can find many tutorials how to do that.But there is a another option which is good in performance wise. You can host the image in a public or private server then store the URL of that image in the DB. Using that URL you can load the image. This is the method which I used in my work. This is good if your image is not contain any valuable information

      • richard

        thanks a lot man. does this rest api support this? , because i want to send image as parameter to asp.net and store it in sql server db. is it possible?

  • master tech

    Hello Ahmad can you please tell me how can I use this API with C#.net

  • Hariz Lobna

    Hi. When I run the project:http://localhost/JSONWebAPI/Handler1.ashx?JDSL, I see the message: { “Successful”: false, “ErrorMessage”: “Internal server error” }. When I run the project whitout Help show the page such as tutorial.

    • Şeyhmus Gümüş

      ı take same mistake im punlish server and local server how do you fix error ?

      • CuneytKukrer

        I had the same problem. Renamed the file “RestAPI” to “Service1” and all instances of the “RestAPI” to “Service1”. And make sure, Handler1.ashx InterfaceConfiguration method has “Service1” as the first parameter. InterfaceConfiguration IConfig = new InterfaceConfiguration(“Service1”, typeof(IServiceAPI), typeof(ServiceAPI));

        Worked!!

    • CuneytKukrer

      I had the same problem. Renamed the file “RestAPI” to “Service1” and all instances of the “RestAPI” to “Service1”. And make sure, Handler1.ashx InterfaceConfiguration method has “Service1” as the first parameter. InterfaceConfiguration IConfig = new InterfaceConfiguration(“Service1”, typeof(IServiceAPI), typeof(ServiceAPI));

      Worked!!

  • David Oddoye

    Any insight on how to use this with javascript?

    • Ahamed Ishak

      You can use this with JavaScrpit. Its better try it your self..

  • Ranjan

    When i go to my localhost with Handler1.aspx?ANDROID.. Handler1.ashx is downloaded

    • karishma

      i’m getting the same problem kindly help me if you have found any fix

      • Sagar

        I am also having same problem. kindly help me if you have found any solution

        • Dhaval Tejlavwala

          same problem

  • kivaraa

    hi ahamed,
    do you know how to retrieve the data from REST in javascript?

  • Marco Bracchi

    Hi Ahamed, very great example! I Have a question: is it possible obtain an update query passing a ContentValue object Android side?

  • richard

    HI Ahamed Ishak yours is a great tutorial so far i used it ,right now i am working on phonegap so can you tell me how to use javascript and fetch data in phonegap.

    • Ahamed Ishak

      Sorry dude. I never used phonegap before.

      • richard

        Ok thanks for your reply man, do u have any idea ?
        To generate JavaScript (dojo with AMD) code use ‘DOJO’ query string like ?ANDROID. if you know where to learn related to this also tell me pls..

  • Guest

    i have this problem try to help me

    • vijeta nagar

      any help with this error ?

  • hamzaabsi

    i have this problem try to help me ?

    • vijeta nagar

      any help with this error ??

  • karishma

    Sir I need you help i have completed the first part but i’m unable to download the APIClient.zip file. When i write “?ANDROID” in the url i’m getting the handler1.ashx file. kindly suggest me a solution.

  • Rajesh Rajendiran

    In local its working fine but when i hosted it in amazon web services I am getting parse error as below

    Server Error in ‘/’ Application.

    Parser Error

    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: Could not create type ‘JSONWebAPI.Handler1’.

    Source Error:

    Line 1:

    Source File: /JSON1/Handler1.ashx Line: 1

    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1008

    help me out from this issue.

    Thanks,
    Rajesh Rajendiran

  • Zack Snyders

    Hi Ahamed,
    The Part 1 tutorial (API) is working perfectly, thank you!
    I now need to develop the front end (mobile part) but would prefer to use Intel XDK where your part 2 tutorial is based on Android ADT.
    The reason for this is that I need to develop for IOS and Android.
    Could you please assist or point me to another tutorial or suggest an alternative to Android ADT and Eclipse?
    Appreciate your help in advance
    rgs

  • karishma

    the webservice has an .ashx extension, will the code remain the same for the .asmx ?

  • Jacqueline

    Hi,

    Can I use Microsoft Visual Studio 2008 to implement this example? Is it compatible ?

    Because, whenever I added in the Json dll into the references. It can’t compile and it displays error:

    Error 1 The type or namespace name ‘JsonServices’ could not be found (are you missing a using directive or an assembly reference?) D:ASP_AndroidWorkplaceJSONWebAPIJSONWebAPIHandler1.ashx.cs 3 7 JSONWebAPI

    Error 2 The type or namespace name ‘JsonServices’ could not be found (are you missing a using directive or an assembly reference?) D:ASP_AndroidWorkplaceJSONWebAPIJSONWebAPIHandler1.ashx.cs 4 7 JSONWebAPI

    Error 3 The type or namespace name ‘JsonHandler’ could not be found (are you missing a using directive or an assembly reference?) D:ASP_AndroidWorkplaceJSONWebAPIJSONWebAPIHandler1.ashx.cs 8 29 JSONWebAPI

    Warning 4 Resolved file has a bad image, no metadata, or is otherwise inaccessible. Could not load file or assembly ‘D:DailyNotesQR_CODEJSONNewtonsoft.Json.dll’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. JSONWebAPI

    Warning 5 Resolved file has a bad image, no metadata, or is otherwise inaccessible. Could not load file or assembly ‘D:DailyNotesQR_CODEJSONJsonServices.Web.dll’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. JSONWebAPI

    Warning 6 Resolved file has a bad image, no metadata, or is otherwise inaccessible. Could not load file or assembly ‘D:DailyNotesQR_CODEJSONJsonServices.dll’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. JSONWebAPI

    Warning 7 The referenced component ‘JsonServices’ could not be found.

    Warning 8 The referenced component ‘JsonServices.Web’ could not be found.

    Warning 9 The referenced component ‘Newtonsoft.Json’ could not be found.

    Can you please tell me what is wrong or what I did wrong? I just follow the tutorial provided. Please help.

    Thank you.

    • Ahamed Ishak

      Did you add the DLL file to your application as references? It seems you was not.

      • Brz

        very important…

        did someone downloaded the APIClient.zip please send to me via mail because i couldn’t download it

        my email :hassanisaeed19@yahoo.com

    • ELHADI

      Thank you v.much MrAkmed Ishak , that is what I need I will try your code

  • Fenil Shah

    Hi…This tutorial works fine but at last, when I use this query: http://localhost:31320/Handler1.ashx?ANDROID , then it downloads .ashx file instead of .zip file.

    • Ahamed Ishak

      There should be a problem in your .NET application.. Try to redo it

      • SUMANT

        I also have same problem..

    • Sagar

      I also have same problem..

    • Pushpender Bhandari

      just save your file as APIClient.zip instead saving handler1.ashx. the problem got solved itself….

    • Brz

      very important…

      did someone downloaded the APIClient.zip please send to me via mail because i couldn’t download it

      my email :hassanisaeed19@yahoo.com

  • ali

    hi ahmad
    thanks for your nice article.
    it works fun.
    but what about sending files(such as images or text files and …) from android application to asp.net server using this way?
    which kind of data types i should use for methods in Service.cs file?
    i want to send images and text files from my android application to server.
    can u explain for these?

    • IrsHaD

      @ali

      why new methods arn’t called 🙁 can u help

  • ali

    can anybody help me to upload files(image,audio,video and …) to asp.net application

  • Nitin

    hi ahmad, how can i change the methods according to my need because i want to pass dynamic query everytime.

  • wu xuerao

    Can you tell me where”Json Services DLL” come from,thanks!

  • Bryan Lighton

    I have used this with great results on android. Do you have any documentation examples for using the same on IOS. I am not sure how to use the resful.h and resful.m files downloaded and how to parse with json to a picker IOS.

  • Şeyhmus Gümüş

    when ı tested my service ı get this error what is wrong with me

    405 Method Not Allowed

    Method Not Allowed
    The HTTP verb used to access this page is not allowed.

    Web Server at seyhmusgumus.com

    <!–
    – Unfortunately, Microsoft has added a clever new
    – "feature" to Internet Explorer. If the text of
    – an error's message is "too small", specifically
    – less than 512 bytes, Internet Explorer returns
    – its own error message. You can turn that off,
    – but it's pretty tricky to find switch called
    – "smart error messages". That means, of course,
    – that short error messages are censored by default.
    – IIS always returns error messages that are long
    – enough to make Internet Explorer happy. The
    – workaround is pretty simple: pad the error
    – message with a big comment like this to push it
    – over the five hundred and twelve bytes minimum.

  • Giovanni Lucasta Bekker

    Hi Ahamed , I’m trying to call the API from a Hybrid Cordova App via iOS and I keep getting a Status:0 error could you please help. I’m not sure why it’s not working as the same code run’s like a dream on an Android device and windows I’m using the JS client.
    Thanks for the good work! Keep it up! Giovanni

  • Giovanni Lucasta Bekker

    O no! I got it to work thanks! my network connection was down….feel so stupid!

  • If it’d Ddd

    I get the following error when trying to run the VS project with http://localhost:63234/Handler1.ashx

    Greg

    Server Error in ‘/’ Application.
    Parser ErrorDescription: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: Could not create type ‘JASONWebAPI.Handler1’.

    Source Error:

    Line 1:

    Source File: /Handler1.ashx Line: 1

    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34212

    • saba

      have you solved this problem??? if yes can you help me out plzzzzzzzz

      • Greg

        Nope, I gave up and went a different route. I call bare-bones web pages from my android app. The pages write data retrieved from the database to a label on the page. The data is formatted in XML which is parsed by my app. May not be as robust as this solution, but at least it works.

        Greg

        • saba

          hey, i solved this 🙂 i just deleted first project and started again, this time i didn’t get the error !!!

        • Pushpender Bhandari

          just check your connection string.

  • hasan123123

    thanks man usefull source.

    • saba

      hey hasan, i am getting error that RestAPI cannot be resolved to a type, plz help me out !!!!

  • Steve

    You are The Fucking Master. Very helpful. Thanks

    • saba

      hey steve, i am getting error that RestAPI cannot be resolved to a type, plz help me out !!!!

  • karishma

    you are great. your tutorial have saved my life. I want to post data to server could you please explain what would be the changes in jsonParser.java, restapi.java and in asp.net. posting data to server will remain same like getting data from server? i mean that data will be post using json?

    • saba

      hey karishma, i am getting error that RestAPI cannot be resolved to a type, plz help me out !!!!

  • IrsHaD

    {

    “Successful”: false,

    “ErrorMessage”: “Internal server error”

    }

    i’m gettin this error.. it’ll b helpful if someone can help 🙂

  • Giovanni Lucasta Bekker

    Could anyone let me know where we can get some documentation on the dll’s that is used in this project? I’m having some trouble where it looks like I’ve reached the max amount of methods to expose. When I add another method the zip file gets corrupted when I try to extract the JS client.

  • IrsHaD

    Whenever I try to create new methods inside JSONWebAPI and calling it from android app..

    I’m getting error : { “Successful”: false, “ErrorMessage”: “Internal server error” }

    I’m unable to successfully create new methods! itz urgent
    help need 🙁

    • disqus_PAe1eYV2IJ

      yeah, I m havin the exact same proble. Dont have a clue how to track dow the error

    • richard

      check your parameters in c# dude..

    • Thabiso Tsitlo Nyokolodi

      hi did you get help regarding Successful”: false, “ErrorMessage”: “Internal server error”, if you did please share

  • richard

    Hi Ahamed Ishak Your tutorial is great i am following it, now i have a requirement to store image in sql server databse from android mobile can you help me how to do it..pls

  • Moshe

    Hey , I realy like your tutorial but how can i secure the api ?
    I want to only my android application access the api .
    please help me with that 🙂

  • Fahim Nasir

    Hello Ahmed, really nice tutorial and it really worked the way you told.
    I have to implement same thing working with Local-IIS.
    I did things accordingly but the authentication is not working for me.

    Here is my service method in ASP.NET (I am using Entity Framework)

    public bool UserAuthentication(string userName, string passsword)
    {
    bool Value = false;
    Value = ctx.User.Any(x => x.Username == userName && x.Password == passsword);
    return Value;
    }

    and here i am calling this in android the same way have done in this tutorial but i can’t login.
    Help Please?

  • Harshad Patel

    Hey Ahmed, thx for this nice example , its working good, but am getting error on somee.com server as i posted image here can u help me to solve this problem

    • Ahamed Ishak

      Check your SQL Query. Its not returning value to department attribute

      • Harshad Patel

        its same site as per ur example, but is there any problem with Somee’s advertise contents ? becoz on another page i have checked data, am getting data on ASP .net page

        • Brz

          very very very important…

          very important…

          did someone downloaded the APIClient.zip please send to me via mail because i couldn’t download it

          my email :hassanisaeed19@yahoo.com

      • Brz

        very very very important…

        did someone downloaded the APIClient.zip please send to me via mail because i couldn’t download it

        my email :hassanisaeed19@yahoo.com

  • saba

    hey Ahmed, i am getting error that RestAPI cannot be resolved to a type, plz help me out !!!!

  • vijeta nagar

    Looks like the dlls are not for .net 3.5.. can anyone pleeeease provide me a link to download dlls for .net 3.5

  • Hed

    did someone downloaded the APIClient.zip please send to me via mail because i couldn’t download it

    gunkilla91@gmail.com @ahamedishak:disqus

  • mani raju

    Hi Ahamed, your tutorial is very helpfull, i have successfully created webapi and hosted in server, but when i try to access the webapi Android client i am just getting the .ashx not the .zip file can you please help me

  • Greg

    Does this not work in VS 2010? I’ve tried three times now, starting over from scratch every time. Following the steps to the letter, and every time I get the same error:

    Parser Error

    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: Could not create type ‘JSONWebAPI2.Handler1’.

    Source Error:

    Line 1:

  • saba

    i want to populate the data in spinner dropdown list from sql server database ,, plz Ahamed can you help me out … its urgent

    • saba

      done it 😀

      • miguel

        hello saba…comments or put code how to solve the populate spinner dropdown please.

  • mani raju

    Hi , can you please explain how to send images to webapi, not by using MVC, but by using webforms

  • vironica

    hello ahmad …you are amazing guy

    but i followed you all. but got this error at the end

    Description: An
    error occurred during the parsing of a resource required to service
    this request. Please review the following specific parse error details
    and modify your source file appropriately.

    Parser Error Message: Could not create type ‘JSONwebAPI.Handler1’.

    Source Error:

    Line 1:

    Source File: /handler1.ashx Line: 1

    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34248

    • Grant

      1. Right click Handler1.aspx and click view markup
      2. Class=”Should be whatever you have for your this.service.name in Handler.aspx.cs

  • litesh sinha

    I am not getting Hndler.aspx file instead of zip file in first part of your this blog please help me

    • Pushpender Bhandari

      save file as CleintAPI.zip extension

    • Adam Scott

      Try :
      localhost:1708/Handler1.ashx/?ANDROID

  • thanks mr ahmad

  • Pushpedner

    how can i create RestAPI for my website developed in asp.NET? so that i can use its data in my android application.!!

  • Pushpedner

    I am getting this error when i tried to get the android file.. please tell me what is wrong with my project?

  • ولی نعیم آبادی

    hello
    this was the best tutorial for restful api.

    i have a question:

    i am using mysql
    can i use this artical?

  • ولی نعیم آبادی

    hi
    how can i upload image or video to asp server in my android app?

    • Pushpender Bhandari

      Did you get your answer regarding uploading image to asp server by asp.net RestAPI??

  • Velmurugan Balu

    Mr.Ahamed Ishak could you please provide sample for uploading audio/video file through Asp.Net Restful API..? It would really be really helpful.

    Great article and good example given by you.

    Thanks.

  • RECEP YESİL

    amazing post
    thanks a lot

  • saba

    thanks a lot…it helped me 🙂

  • Thabiso Tsitlo Nyokolodi

    Hi Ahamed Ishak,

    I followed you steps exactly as the are how ever my app always return incorect username/password, may you please assist me here i am using android studio

  • Thabiso Tsitlo Nyokolodi

    i am getting Successful”: false, “ErrorMessage”: “Internal server error”, can anyone please help

    • ann

      same here pls help

  • Cậu Gà

    thanks you so much! but I have a error.

    • Brz

      Very Very important…..

      I can’t download APIClient.zip
      can you send that file to my email?!
      Thanks
      my email : hassanisaeed19@yahoo.com

  • Cậu Gà

    how do my show my json???

  • MKO

    Hi there,

    Is there newer version of JsonServices.dll? I would like to also use it in Windows Apps?

    I can’t use the CSHARP version because Windows Apps requires Async methods to get Request/Responce streams.

  • krishna

    Hello friends,
    I have done first part of this article, but in second part there are some java code so i am confused with it.
    Please help me to fetching and storing data in SQL server, i am working in Intel XDK.

    If there are any references or useful stuff send me at 20krish@gmail.com

  • Adi

    Hello people, could you please help me out with this error. Thanks in advance. Have a nice day all.

  • Jason Davidson

    Hi, Thank you for a great tutorial. is it possible to please get the dll’s for .Net 3.5?

    • Brz

      very important…
      ………
      did someone downloaded the APIClient.zip please send to me via mail because i couldn’t download it

      my email :hassanisaeed19@yahoo.com

    • Brz

      very important…

      did someone downloaded the APIClient.zip please send to me via mail because i couldn’t download it

      my email :hassanisaeed19@yahoo.com

      • ahsan butt

        have u got the solution?? if yes then send me here ahsanb634@gmail.com thnxx in advance……….

  • Sunil Bhatia

    Hi I am not able to downlao the source code and dll files

      • Sunil Bhatia

        thanks for your help do you have links for source code also both part 1 and part 2 for android

        • Brz

          very important…
          …..
          did someone downloaded the APIClient.zip please send to me via mail because i couldn’t download it

          my email :hassanisaeed19@yahoo.com

          • ahsan butt

            have u got the solution?? if yes then send me here ahsanb634@gmail.com thnxx in advance..

        • Brz

          very important…–

          did someone downloaded the APIClient.zip please send to me via mail because i couldn’t download it

          my email :hassanisaeed19@yahoo.com

          • ahsan butt

            have u got the solution?? if yes then send me here ahsanb634@gmail.com thnxx in advance.

        • unfortunately no..

      • Brz

        I can’t download APIClient.zip
        can you send that file to my email?!
        Thanks
        my email : hassanisaeed19@yahoo.com

      • Brz

        very important…

        did someone downloaded the APIClient.zip please send to me via mail because i couldn’t download it

        my email :hassanisaeed19@yahoo.com

      • Brz

        very important…
        ,
        did someone downloaded the APIClient.zip please send to me via mail because i couldn’t download it

        my email :hassanisaeed19@yahoo.com

    • Brz

      very important…
      …………………….
      did someone downloaded the APIClient.zip please send to me via mail because i couldn’t download it

      my email :hassanisaeed19@yahoo.com

  • Pushpender Bhandari

    Can anyone tell me how to upload image to server by Rest API?

  • Anand

    Hi can somebody please share the source files?

  • Anand

    Hi Ahmad,

    Is it possible to do call backs from the service ?

    • Brz

      very important…
      .
      did someone downloaded the APIClient.zip please send to me via mail because i couldn’t download it

      my email :hassanisaeed19@yahoo.com

      • ahsan butt

        have u got the solution?? if yes then send me here ahsanb634@gmail.com thnxx in advance//

  • Abhishek Pandey

    Sir i am not able to download the sample project not even it’s JSON.dll file can you plz provide me this sample over my email address my email id is abhishekpandey151@gmail.com

    • Brz

      very important…
      ..
      did someone downloaded the APIClient.zip please send to me via mail because i couldn’t download it

      my email :hassanisaeed19@yahoo.com

  • 陈嘉伟

    Sir I failed to download JSON.dll file as well, can you please send me a copy to my email stansze2@gmail.com

    • Brz

      Very important…..

      I can’t download APIClient.zip
      can you send that file to my email?!
      Thanks
      my email : hassanisaeed19@yahoo.com

  • rur

    hi friends can someone send me json.dll and sample code in my email rurajuu@gmail.com

  • Rick Anthony G Portes

    Hello Sir thank you for tutorial which will be a big help for our thesis Android messaging application. Now why I’m gettint this error?

    Web.config updates
    ConString “connectionString=”Data Source=DESKTOP-QJDF0RA; Iniital Catalog=AndroidAppDB; Integrated Security= True” providerName=”System.Data.SqlClient”/>

    Looking forward for your reply. THANKS in advance.

    • Rick Anthony G Portes

      Sir nevermind my question I already solved the problem by using this code

    • Khouloud Dridi

      this is the correct one

  • Khouloud Dridi

    please can any one send me the json service dll files at khoulouddridi25@gmail.com because i can’t get them

    thanks

    • ahsan butt

      hello i am downloading .ashx of handler instead of zip file .. kindly help me in resolving this error or what and i am using visual studio 2015

  • Gebrehiwot Reda

    i can’t donwload APIClient.zip
    can anyone send the file to my email?
    my email:gebrehiwotreda@gmail.com

  • Aizaz

    Hi I Have an error when i run RestApi.java file on genymotion

    getJsonArray(“Value”);
    What is the parameter named “Value” come from??/?
    It throw excaptio : No value found for “value”

  • Aizaz

    Please tell me i am struck in this error ,,,,

  • ahsan butt

    hello guys i am downloading .ashx of handler instead of zip file .. kindly someone help me in resolving this error or what and i am using visual studio 2015

    • Khouloud Dridi

      I suggest that you create your own project and follow the steps

      • ahsan butt

        i have already created another project but facing the same project it downloads ashx file instead of zip

        • Khouloud Dridi

          that’s right it generate java and xml together but the generated code is right
          you should copy the java code and put it in a an other file with the extension .java
          because you can’t use the ashx directly

          2016-06-03 19:48 GMT+02:00 Disqus :

          • ahsan butt

            thnx but can u show me some screen shots if u have … thnx

          • Khouloud Dridi

            screenshots of the rest client or the asp.net web api ??

          • ahsan butt

            yes thnx

      • ahsan butt

        thnks it works but how can i connect this with my real android phone? guide me please

  • narayan chiduruppa

    where is source code of android plzz send me to my Email id
    narayanchiduruppa@gmail.com

  • mukesh

    how to use restful API on my android app ?

  • Ramesh Krishnan

    hi ahamed, i ve created my own rest api from your example, i am getting a parser error when i run the asp.net. Could you please find time to reply me regarding this. Following is the error am getting while running the prog.
    ” Could not create type ‘FOLLOWUPAPI.patientfollowup’.”

  • Ali Ben Chaabene

    i can’t donwload APIClient.zip !!!!
    help plzz

  • Lovedeep Singh

    sir i am facing same error after fill the http://localhost:7541/Handler1.ashx url in url baar

  • Lovedeep Singh

    pleas check out the error sir

    • Yasemin Göktaş

      Hello,
      I had the same mistake. One of the dropboxes shared all the DLLs below. Download the there and add them as references. Do not add any other DLLs. Also make sure your codes are exactly the same.

  • Saurav Tyagi

    can anyone send me the sample code as download sample code button is not working…..
    my mail-id is tsaurav94@gmail.com
    thanks in advance

  • Saad Zafar

    https://uploads.disquscdn.com/images/019a205bfa939fa100b257f6437620b7ef7973a2679f59a4162076074ff00ea1.png

    Sir please help me I stuck in this
    It is a declaration Expected error.