First, create Web API using Azure SQL Server. Refer to part one:
Step 1
Open Visual Studio, New Project, Templates, Visual C#, Android, then select Blank App (Android).
Select Blank App. Then give Project Name and Project Location.
Step 2
Next go to Solution Explorer-> Project Name-> Resouces->layout then Right Click to Add then open new Dialog box. Then select Android Layout give name for Reg.axml after that Add New Layout Page.

Step 3
Next go to Solution Explorer-> Project Name then Right Click to Add then open new Dialog box. Then select Activity give name for NewUserActivity.cs after that Add the New Activity Class.

Step 4
Next we need add one Data Layer Class. Go to Solution Explorer-> Project Name then Right Click to Add then open new Dialog box. Then select Class give name for Login.cs after that Add New Class.
Step 5
Next go to Solution Explorer-> Project Name-> References then Right Click to Manage Nuget Packages then open new Dialog box. This dialog box to search the Json then Install the Newtonsoft.Json Packages.
Step 6
Next go to Open Solution Explorer-> Project Name->Resources->layout->Main.axml Click Open Design View. Here create Large Text, Two Plain Text and Two Buttons.
Step 7
Next to Open Solution Explorer-> Project Name->Resources->layout->Reg.axml Click Open Design View. Here create Large Text, Two Plain Text and One Buttons.
Step 8
Next to Open Solution Explorer-> Project Name->Login.cs Click Open CS code Page View then create two class name Username and Password.
- public string username { get; set; }
- public string password { get; set; }
Step 9
Next to Open Solution Explorer-> Project Name->MainActivity.cs Click Open CS code Page view then add below namespaces. Next to write given below code.
- using System.Net.Http;
- using System.Net.Http.Headers;
C# Code
- public class MainActivity: Activity
- {
- EditText txtusername;
- EditText txtPassword;
- Button btncreate;
- Button btnsign;
- protected override void OnCreate(Bundle bundle)
- {
- base.OnCreate(bundle);
-
- SetContentView(Resource.Layout.Main);
-
-
- btnsign = FindViewById < Button > (Resource.Id.btnloglogin);
- btncreate = FindViewById < Button > (Resource.Id.btnlogreg);
- txtusername = FindViewById < EditText > (Resource.Id.txtlogusername);
- txtPassword = FindViewById < EditText > (Resource.Id.txtlogpassword);
- btncreate.Click += Btncreate_Click;
- btnsign.Click += Btnsign_Click;
- }
- private async void Btnsign_Click(object sender, EventArgs e)
- {
- HttpClient client = new HttpClient();
- var uri = new Uri(string.Format("http://xamarinlogin.azurewebsites.net/api/Login?username=" + txtusername.Text + "&password=" + txtPassword.Text));
- HttpResponseMessage response;;
- client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- response = await client.GetAsync(uri);
- if (response.StatusCode == System.Net.HttpStatusCode.Accepted)
- {
- var errorMessage1 = response.Content.ReadAsStringAsync().Result.Replace("\\", "").Trim(new char[1]
- {
- '"'
- });
- Toast.MakeText(this, errorMessage1, ToastLength.Long).Show();
- }
- else
- {
- var errorMessage1 = response.Content.ReadAsStringAsync().Result.Replace("\\", "").Trim(new char[1]
- {
- '"'
- });
- Toast.MakeText(this, errorMessage1, ToastLength.Long).Show();
- }
- }
- private void Btncreate_Click(object sender, EventArgs e)
- {
- StartActivity(typeof(NewUserActivity));
- }
- }
Step 10
Next to Open Solution Explorer-> Project Name->NewUserActivity.cs Click Open CS code Page view then add below namespaces. Next to write given below code.
- using System.Net.Http;
- using System.Net.Http.Headers;
- using Newtonsoft.Json;
C# Code
- public class NewUserActivity: Activity
- {
- EditText txtusername;
- EditText txtPassword;
- Button btncreate;
- protected override void OnCreate(Bundle savedInstanceState)
- {
- base.OnCreate(savedInstanceState);
-
- SetContentView(Resource.Layout.Reg);
- txtusername = FindViewById < EditText > (Resource.Id.txtsaveusername);
- txtPassword = FindViewById < EditText > (Resource.Id.txtsavepassword);
- btncreate = FindViewById < Button > (Resource.Id.btnsavecreate);
- btncreate.Click += Btncreate_Click;
- }
- private async void Btncreate_Click(object sender, EventArgs e)
- {
- Login log = new Login();
- log.username = txtusername.Text;
- log.password = txtPassword.Text;
- HttpClient client = new HttpClient();
- string url = "http://xamarinlogin.azurewebsites.net/api/Login/";
- var uri = new Uri(url);
- client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- HttpResponseMessage response;
- var json = JsonConvert.SerializeObject(log);
- var content = new StringContent(json, Encoding.UTF8, "application/json");
- response = await client.PostAsync(uri, content);
- if (response.StatusCode == System.Net.HttpStatusCode.Accepted)
- {
- var errorMessage1 = response.Content.ReadAsStringAsync().Result.Replace("\\", "").Trim(new char[1]
- {
- '"'
- });
- Toast.MakeText(this, errorMessage1, ToastLength.Long).Show();
- }
- else
- {
- var errorMessage1 = response.Content.ReadAsStringAsync().Result.Replace("\\", "").Trim(new char[1]
- {
- '"'
- });
- Toast.MakeText(this, errorMessage1, ToastLength.Long).Show();
- }
- }
- }
Step 11
Press F5 or Build and Run the Application, first image to register the new user and then next image to login the user.
Finally, we have successfully created Login with WEB API Using Azure SQL Server.
Hrishikesh GarudPosted Nov 18, 2020, 2:41 PM
Error - "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable"
Khaled mahmoudPosted May 11, 2020, 10:26 AM
"$id":"1","message":"No HTTP resource was found that matches the request URI
Viknaraj ManogararajahPosted Jul 27, 2018, 10:12 AM
nice article anbu
ADNAN MISTRYPosted Jul 26, 2018, 10:09 AM
I am getting unhandled exception error at response = await client.GetAsync(uri);
Niels de VriesPosted Jun 26, 2018, 2:44 AM
Hi Anbu, thanks for your articles. However I still get the error message as others are commenting; {"$id":"1","message":"No HTTP resource was found that matches the request URI . I checked my routing and I am not using localhost. Do you have any suggestions what to do?
Wendell RamosPosted Feb 26, 2018, 12:07 AM
What if the API is self hosted? like WPF api, but its still a xml/json file. What i want sir is, how can i make the validation from the application? Not from the Azure app. How to make own validation from android. Thanks in advance :)
Yehudy MoyaPosted Jun 19, 2017, 2:23 PM
Hi Anbu Mani I have the same problem: if I try to create a user by code, I get an error that no Http resource was found that matches the request uri...Even though I'm choosing the same url for both POST and GET, seems like in the Post request, the parameters are not being sent. "{"$id":"1","message":"No HTTP resource was found that matches the request URI = "xxxxxxxxxxxxxxxxxxxxxxxx"...... Whrere Check "WEB API Routing" I dont understand.. Please helpme... Thanks
Wael ElZahrPosted Jun 18, 2017, 12:58 PM
Thanks for the tutorial. The Login works well if I add a user from the db. However, if I try to create a user by code, I get an error that no Http resource was found that matches the request uri...Even though I'm choosing the same url for both POST and GET, seems like in the Post request, the parameters are not being sent. ANy ideas?
Theodorus GumilangPosted Jun 12, 2017, 10:06 PM
I have some error , when i create new user its said no HTTP reource was found that mactchse the reuques URl "http://xamari/nlogin20170612105003.azurewebsites.net/api/Login" is this right url to create user ? or my url is wrong ?
Fawad MehmoodPosted May 16, 2017, 1:02 PM
I am getting below message
kannan rPosted May 3, 2017, 4:19 AM
Hi Mani, in debug it working but in release app close i don't know what the issue
My HockeyPosted Nov 15, 2016, 9:42 AM
Thank you, that's realy work!
Kashif Ahmad KhanPosted Sep 16, 2016, 2:16 AM
Thanks for the helpful article...
Davronbek UmirovPosted Jun 9, 2016, 7:19 AM
Thanks for the article.. helped me!
Santhakumar MunuswamyPosted Jun 9, 2016, 12:40 AM
Thank you for nice share
Debasis SahaPosted Jun 8, 2016, 10:14 AM
Good One..
Kuppurasu NagarajPosted Jun 6, 2016, 12:00 PM
Nice Sharing..
Sonu ChaudharyPosted Jun 6, 2016, 9:44 AM
good one...
Vignesh ManiPosted Jun 6, 2016, 5:30 AM
Nice one
RajaPosted Jun 6, 2016, 12:21 AM
Nice article...
Debasis SahaPosted Jun 6, 2016, 12:18 AM
Good One..
Bhavik PatelPosted Jun 4, 2016, 11:19 PM
nice