Options

Using Web Services in C#

dmauldindmauldin Member Posts: 37
edited 2010-10-22 in NAV Three Tier
I followed the walkthrough to start learning how to connect to web services in Nav 2009.

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

I typed in the code exactly as it is, but when I run it, I get a WebException was unhandled error at the




Customer[] list = service.ReadMultiple(filter.ToArray(), null, 100);

line. The error says 'The request failed with HTTP status 401: Unauthorized'.

Does anyone have an idea of what is causing this and how I can fix it?

Comments

  • Options
    kinekine Member Posts: 12,562
    User, under which you are running the application, must have correct permissions in NAV...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    dmauldindmauldin Member Posts: 37
    I gave that user super user rights and I still get the error.
  • Options
    vedant18vedant18 Member Posts: 22
    hi

    U can Try This Code

    service.UseDefaultCredentials = False;
    service.Credentials = New System.Net.NetworkCredential(UserName,Password);
    _________________
    Senior NAV Developer
    Microsoft Dynamics NAV
  • Options
    dmauldindmauldin Member Posts: 37
    I was able to do as vedant18 suggested and it worked. But of course i don't want to hard code a username and password. We will be using web services from our web site for customers to send in info. I'd like to use service.UseDefaultCredentials = true, but I keep getting the 401 Unauthorized when it creates the customer. We setup delegation but this still isn't working. Any ideas?
  • Options
    vedant18vedant18 Member Posts: 22
    Hi dmauldin,
    Windows Authentication on iis website ?
    _________________
    Senior NAV Developer
    Microsoft Dynamics NAV
Sign In or Register to comment.