Mono for Android using a web service with authorization

I am developing an Android application that uses a web service. I added a link to the web service for my project (right-click on the project → Add web link). When I use the web service without authentication, everything works fine, but when I set the credentials, they just don't work. I get this error:

Request Error with HTTP Status 401: Unauthorized

Can someone help me?

This is the function of the button click event:

button.Click += delegate { WebReference.WebPhysInvPocess client = new WebReference.WebPhysInvPocess(); //this is my web service client.Credentials = new NetworkCredential("username", "password"); //adding crediantials //client.Url = @"http://localhost:7053/DynamicsNAV-NAV6R2Prototype/WS/NVB%20Prototype/Codeunit/WebPhysInvPocess"; string blabla = ""; try { client.CratePhysInvBatch("S001", "RAUDONAS", ref blabla, "test"); TextView txt = FindViewById<TextView>(Resource.Id.textView1); } catch (Exception e) { TextView txt = FindViewById<TextView>(Resource.Id.textView1); txt.Text = e.Message; } }; 

When I compile the code as a Windows.net application, everything works.

+4
source share
1 answer

Have you checked your delegation?

0
source

Source: https://habr.com/ru/post/1446880/


All Articles