I spent more than 4 hours to resolve the following error.
“The HTTP request is unauthorized with client authentication scheme ‘Anonymous’. The authentication header received from the server was ‘NTLM’.”
I got this error when I tried to write a simple call “GetList(“Site Pages”) ” from List.ASMX service.
TO RESOLVE Do the following steps, after adding web reference to the service on a simple console application. using “http://[YOUR HOST HERE]/_vti_bin/lists.asmx”
1. Add the following line
ServiceReference1.ListsSoapClient list = new ServiceReference1.ListsSoapClient();
list.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
2. Also make sure in the app.config file you have the following.
<security mode="TransportCredentialOnly"> <transport clientCredentialType="Ntlm" proxyCredentialType="Ntlm" realm=""/> <message clientCredentialType="UserName" algorithmSuite="Default"/> </security>
I hope this helps, if you have the same error.
Thanks, this saved me a good bit of time. I was missing the security mode from other articles on this issue that I had read.
Thanks again!
+1