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 :
Finance | Project Operations, Human Resources, ...
Suggested answer

Unauthorized error when running recurring job

(0) ShareShare
ReportReport
Posted on by 1,552

I created a recurring job   

i did POST in postman to get the access token and i got it successfully.  login.microsoftonline.com/.../token

 now i did GET to this URL

 EnvURL/api/connector/dequeue/%7BActivityId%7D   // the activity ID is the ID field i get in managed scheduled data jobs

 I chose Oauth2.0 in the authorization tab and inserted the access token (bearer)

 But i'm getting 401 any idea?

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Unauthorized error when running recurring job

    For the first question, the documentation says you should use login.microsoftonline.com/.../

    https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols#endpoints

    For the second question, you can use login.windows.net/company.com or the directory id (guid) from AAD. Both work.

    In general, you can refer to AAD documentation with such questions, they are not specific to D365FO.

  • junior AX Profile Picture
    1,552 on at
    RE: Unauthorized error when running recurring job

    Hi Nikolaos,

    I knew the issue without debugging, it seems I filled the activityId with clientId. So now it works

    As for Postman, the issue was naming one of the variables, it was a small typo i don't know how i got a token though if the name was wrong.

    I have two questions,

    there are two urls i can use to get the token

    1. login.microsoftonline.com/tenantid/token  [Here i replaced tenantId with company.com]

    2. login.windows.net/tenantid/token  [Here i also replaced tenantId with company.com]

    both works but which one  is the correct one?

    and when i used custom services code from github i used to replace ActiveDirectoryTenant with              "login.windows.net/company.com"

    So I'm confused now what is tenantId

    1. company.com or login.windows.net/company.com or the DirectoryId from Azure (which is guid)

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Unauthorized error when running recurring job

    Hi junior AX,

    Set the Scheduler project as startup project. Then click Start in the top bar of Visual Studio. It starts the scheduler, and you can debug what happens in the code.

    Yes, it's a good idea to put a breakpoint in Download.cs.

    Also AUthenticationHelper.cs is useful.

    You don't need to write any code. The code works, you just need to debug it to understand what exact part in the authentication and download process fails, and why.

  • junior AX Profile Picture
    1,552 on at
    RE: Unauthorized error when running recurring job

    Hi Nikoloas,

    I downloaded VS2019. What should i do next?

    i think i should set scheduler project as a startup object. And i should put debug points on project job.download?

    but what should i do exactly? should i write any code? and should i start the scheduler app as well?

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Unauthorized error when running recurring job

    Hi, I really think that you need to debug it.

    Why can't you install VS 2019?

    If your organizational policies are preventing you from doing your dev work, you need to discuss that in your organization. But you definetely need to have admin access in your dev system in order to do dev work effectively.

  • junior AX Profile Picture
    1,552 on at
    RE: Unauthorized error when running recurring job

    Hi Nikolaos and Mohammad,

    I validated the connection from scheduler app

    pastedimage1602077054415v1.png

    The problem is i can only download the app on VM and i can't access the code as it's VS2015. Is there another way to know what the authentication issue could be? As i said before i was able to get the access token from postman but i couldn't call the dequeue from postman as I got unauthorized.

  • Suggested answer
    mhdshb1 Profile Picture
    1,250 on at
    RE: Unauthorized error when running recurring job

    Hi,

    Did you update the service to service Azure app registration ?

    Did you test the connection from the scheduler?

    Most probably it is an authentication issue.

  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Unauthorized error when running recurring job

    This means that the scheduler hasn't been able to download the message. Since you now have the source code for RIS, you can debug the process to see where it fails. Perhaps you get the same "Unauthorized" error that you mentioned in your original question.

  • junior AX Profile Picture
    1,552 on at
    RE: Unauthorized error when running recurring job

    Hi Nikolaos,

    I mean if i go to execution details, i'll see that the export is done and 1 record is exported. But no the status is still processed.

    I can't find downloaded or acknowledged statuses. So why i'm not able to get the files using scheduler?

  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Unauthorized error when running recurring job

    What do you mean that "in DMF it says the export is done succesfully"?

    In DMF the job status is "Acknowledged" after succesful export. Is it?

    When DMF itself creates the file and puts it in D365FO outbound queue, the status is Processed. Once the external app downloads it, the status is Downloaded. And finally, after the external app sends the ack message, the status changes to Acknowledged.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 846 Super User 2025 Season 2

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 838

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 818 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans