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.

http://msdn.microsoft.com/en-us/library/gg334316.aspx

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

http://<servername[:port]>/mscrmservices/2007/crmservice.asmx?WSDL&uniquename=organizationName


details here


http://msdn.microsoft.com/en-us/library/cc151015.aspx


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");



 



source http://social.microsoft.com/Forums/en/crmdevelopment/thread/fd97215a-454f-4875-b7c9-9b2fbefa0f10



and eureka its working man.. took my 3 hours

No comments:

Post a Comment