In this post, we will solve “The HTTP request is unauthorized with client authentication scheme ‘Anonymous’ ” that you may face when authenticate tp the Project Server using PSI.
You might also like to read Update Enterprise Custom Field Value using PSI in Project Server
In Project Server 2013, I am trying to read the projects using PSI. but I had noticed that when debug the solution I got the below exception message:
The HTTP request is unauthorized with client authentication scheme ‘Anonymous’. The authentication header received from the server was ‘NTLM’
This exception specifically occurred when at the below line of code:
ProjectSoapClient projectSvc = new ProjectSoapClient();
projectSvc.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
projectSvc.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
Cause
This exception usually occurs if app.config security tag is not configured properly!
Solution
To overcome this exception, you should configure the app.config structure properly by doing the following :
- Make sure that Security Tag has been structured as the following:
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" />
</security>
- Make sure that binding Tag has been structured as the following:
<binding name="ProjectSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
proxyAddress="Type your proxy URL here" hostNameComparisonMode="StrongWildcard"
maxBufferSize="200000000" maxBufferPoolSize="200000000" maxReceivedMessageSize="200000000"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="false">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" />
</security>
</binding>
The final app.config structure should look like the following:
- Go back to run your solution that should be worked properly now.
Applies To
- Project Server 2013.
- Project Server 2010.