web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Microsoft CRM Webservices - 401 unauthorized

(0) ShareShare
ReportReport
Posted on by 50
I am having issues adding new records to the CRM using Microsoft web service. I keep getting the 401 unauthorized.  Any idea on how CRM handles priviledges through web services will be useful.     Sample error message----------------------------------Unable to Create new RecordSystem.Net.WebException: The request failed with HTTP status 401: Unauthorized.   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)   at CRM.Proxy.CrmSdk.CrmService.Create(BusinessEntity entity)   at TestCRMConsole.Program.Main(String[] args) in E:\RCICODES\RCIStageCodes\TestCRMConsole\TestCRMConsole\Program.cs:line 42   sample code used-----------------------------------static void Main(string[] args)        {                                     CrmAuthenticationToken token = new CrmAuthenticationToken();                token.AuthenticationType = 0;                token.OrganizationName = "Together";                                           CrmService service = new CrmService();                service.Url = "http://rci-lab-crm/mscrmservices/2007/CrmService.asmx";                               //service.Credentials = System.Net.CredentialCache.DefaultCredentials;                              service.CrmAuthenticationTokenValue = token;                service.Credentials = new System.Net.NetworkCredential("XXX", "XXXX", "together");                 contact SampleContact = new contact();                SampleContact.firstname = "John";                SampleContact.lastname = "Doe";                SampleContact.telephone1 = "561-222-2222";                SampleContact.emailaddress1 = "Email Protected";             try            {                service.Create(SampleContact);            }            catch (Exception Ex)            {                Console.WriteLine("Unable to Create new Record" + Ex);            }                       Console.WriteLine("WAIT");            Console.Read();        }

 

*This post is locked for comments

I have the same question (0)
  • Mitch Milam Profile Picture
    on at
    Re: Microsoft CRM Webservices - 401 unauthorized

    The user you are using for the NetworkCredentials must also be a user within CRM and have approprate priviledges to perform whatever operation you are requesting.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Christoph Pock Profile Picture

Christoph Pock 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans