401 error when calling a function of a published CodeUnit

AitorEGAitorEG 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:

4n5ppec6j5ak.png

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!

Best Answers

  • AitorEGAitorEG Member Posts: 342
    Answer ✓
    solved with:
    ws.Credentials = new System.Net.NetworkCredential("user", "pwd", "domain");

Answers

  • HannesHolstHannesHolst Member Posts: 119
    Hi,

    I would start to investigate based on the http error code. 401 represents an error in authorisation.
    https://httpstatuses.com/401

    Good luck.
  • AitorEGAitorEG Member Posts: 342
    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...
  • AitorEGAitorEG Member Posts: 342
    Answer ✓
    solved with:
    ws.Credentials = new System.Net.NetworkCredential("user", "pwd", "domain");
Sign In or Register to comment.