Search code examples
c#soapunauthorizeddynamics-navmicrosoft-dynamics-nav

dynamics nav webservice error 401 Unauthorized


When consuming a dynamics nav web service I get the following error :

The request failed with HTTP status 401: Unauthorized.

However when I try it in a browser it works . I tried the following but its still not working :

service.UseDefaultCredentials = true;
service.PreAuthenticate = true;

also :

service.Credentials = new System.Net.NetworkCredential("XXXXX", "XXXX","XXXX");

I even tried using dynamics nav acces key but also it didn't work.

Any new suggestions ?


Solution

  • I know this thread is more than 4 years old, but i thought if somone is currently searching for this problem he will come across this trhead, like me.

    There is currently a problem with NTLM and Xamarin (at the moment i write this, the problem also exists in .net core on MacOS).

    See the links:

    iOS: https://github.com/xamarin/xamarin-macios/issues/7770

    Android: https://developercommunity.visualstudio.com/content/problem/756697/last-visual-studio-update-brakes-ntlm-authenticati.html

    The solution is to use the "MonoWebRequestHandler". For a combined Android and iOS Solution check my latest post here

    I hope i could save somones time with this post!