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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Unauthorized response when calling JSON web service

(0) ShareShare
ReportReport
Posted on by 692

Hi

I am trying to call the GetUserSessionInfo web service using the sample code from Microsoft but it is failing with the error "Unauthorized" when the request to the service url is posted.

As far as I can see I have filled in the parameters in the ClientConfiguration.cs correctly and my user is a system administrator. I have created a native app registration in azure as per the guide here: https://ax.help.dynamics.com/en/wiki/dynamics-ax-7-services-technical-concepts-guide/

Can anyone suggest what I might be doing wrong please?

Any help would be most appreciated.

Thanks,
Joe

*This post is locked for comments

I have the same question (0)
  • Mohd saddaf khan Profile Picture
    20 on at

    Hello Joe,

    I hope You would have followed all the steps. But I am mentioning the checklist again here, please verify

    1. Register Native App on Azure portal.

    2. Note down the newly created App id.

    3. configure Dynamics AX access consent for this App on Azure portal.

    4. Add the Redirect Uri on the App page(this will be same as AX URL mention the same URL and do not alter the character casing).

    5. Go to the client configuration class on C# project you are using to get Access code.

    6. on URISTRING, suffix it with "/"

    7. Username & password will be your login credentials.

    8. "ActiveDirectoryResource" would be same as AX URL.

    9.  ActiveDirectoryTenant = "login.windows.net/<tenantId>"

    10. ActiveDirectoryClientAppId = "Native App ID from step 2"

    Run the project, you would surely get Access code.

    After getting access code, prefix it with 'bearer' to Access JSON based services from AX.

    Thanks,

    Saddaf khan

  • JoeBrewer Profile Picture
    692 on at

    Hi Saddaf

    Thanks for your reply. I believe I have done these steps correctly. When debugging the code it fails when it is calling the service which is after it has retrieved the authorisation header

    0333.Capture.PNG

    Joe

  • Mohd saddaf khan Profile Picture
    20 on at

    Above code is looking fine and same is working for me.

    Please re-verify the Redirect Uri under Native App.

  • JoeBrewer Profile Picture
    692 on at

    I have made some progress in a way. I now know that my code fails when it tries to communicate with a Microsoft hosted environment. If I I try to communicate with a web service on an environment that I deployed using the azure credit from my MSDN subscription the code works fine.

    In the event logs on the Microsoft environment there is this:

    Web API Owin Authentication Configuration Missing Error

    Failed validating token '{"typ":"JWT","alg":"RS256","x5t":"a3QN0BZS7s4nN-BdrjbF0Y_LdMM","kid":"a3QN0BZS7s4nN-BdrjbF0Y_LdMM"}.{"aud": etc etc etc

    Has anyone seen this before?

    Thanks,

    Joe

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans