401 error when calling a function of a published CodeUnit

AitorEG
Member Posts: 342
Hello everyone,
I've got a problem when calling to a function of a codeunit published as a WebService. This is the past of the code where I call the function, and the error:

Have to say, that I have other codeunit published, and I execute every day functions from that CU, calling them from Console Applications, scheduled periodically in the server.
So, basically, the difference between the 2 scenarios, is that in the case that generates a 401 error:
1- I'm calling the function from a ASP.net WebApp instead of a Console application
2-The functions return a value to the app
Any hint about this issue?
Thank you very much!
I've got a problem when calling to a function of a codeunit published as a WebService. This is the past of the code where I call the function, and the error:

Have to say, that I have other codeunit published, and I execute every day functions from that CU, calling them from Console Applications, scheduled periodically in the server.
So, basically, the difference between the 2 scenarios, is that in the case that generates a 401 error:
1- I'm calling the function from a ASP.net WebApp instead of a Console application
2-The functions return a value to the app
Any hint about this issue?
Thank you very much!
0
Best Answers
-
solved with:
ws.Credentials = new System.Net.NetworkCredential("user", "pwd", "domain");0 -
solved with:
ws.Credentials = new System.Net.NetworkCredential("user", "pwd", "domain");
Hi Aitor,
Using user/password is one solution. If you do not want to handle the password security inside your code then you can try to configure your web server for windows authentication (disable anonymous authentication) and, if needed, configure delegation between your NAV server and your web server.
I hope this will help someone5
Answers
-
Hi,
I would start to investigate based on the http error code. 401 represents an error in authorisation.
https://httpstatuses.com/401
Good luck.My blog - https://www.HannesHolst.com/0 -
HannesHolst wrote: »Hi,
I would start to investigate based on the http error code. 401 represents an error in authorisation.
https://httpstatuses.com/401
Good luck.
Thank you for your answer Hannes, I understand what that error means. But I'm quite lost becasuse has I've said, I already have console apllications running function from another CoudeUnit without any problem. So the problem probably will lie on the differences I exposed before. If the problem has to do with the task of returning a value from the codeunit, I think i should gave some autorization to the server instance, am I right? Because I'm quite sure it's not an ASP or console application issue...0 -
solved with:
ws.Credentials = new System.Net.NetworkCredential("user", "pwd", "domain");0 -
solved with:
ws.Credentials = new System.Net.NetworkCredential("user", "pwd", "domain");
Hi Aitor,
Using user/password is one solution. If you do not want to handle the password security inside your code then you can try to configure your web server for windows authentication (disable anonymous authentication) and, if needed, configure delegation between your NAV server and your web server.
I hope this will help someone5
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions