Wednesday, May 25, 2011

CRM 2011 CRMservice.asmx 401 unauthorized

recently updated from 4.0 to 2011 found a link stating that don’t have to write whole chunk of code rather I can use this url for backward compatibility.

so become more than happy however code was not working as required and throwing 401 upon creating lead and cases. so I had to to following things


1) I had to remove existing web reference and had to update it with


details here

then I had to add this code segment on 

CrmAuthenticationToken token = new CrmAuthenticationToken();

token.OrganizationName = "OrganizationName";

_crmService = new CrmService();

_crmService.Credentials = System.Net.CredentialCache.DefaultCredentials;

_crmService.CrmAuthenticationTokenValue = token;

_crmService.PreAuthenticate = true;

_crmService.Credentials = new System.Net.NetworkCredential(testdomainlogin", "testdomainpassword", "EA");



and eureka its working man.. took my 3 hours

No comments: