question

Steffen-0727 avatar image
0 Votes"
Steffen-0727 asked Steffen-0727 commented

Listing business central companies results in 401 unathorized

I am attempting a Graph api call as described here:
https://docs.microsoft.com/en-us/graph/api/dynamics-companies-get?view=graph-rest-beta

I have retrieved a valid access token. To test the token validity, I can successfully list groups from '/beta/groups/'. The user associated with the access token, can log into Business Central.

Viewing the access token through jwt.ms shows that:

  • The access token has not expired.

  • Permissions include 'Financials.ReadWrite.All'. Full set: Financials.ReadWrite.All Group.ReadWrite.All User.Read profile openid email

The raw HTTP request looks like this:

GET /beta/financials/companies HTTP/1.1
Host: graph.microsoft.com
Authorization: Bearer ...

(With no body)

The response is 401 Unauthorized, with JSON body:

{"error":{"code":"Authentication_InvalidCredentials","message":"The server has rejected the client credentials. CorrelationId: 1c60c7bc-8b89-4a14-bc6e-3926cde7b261.","innerError":{"date":"2021-05-26T09:46:29","request-id":"0751c960-828b-4887-bac2-ceed122aeebb","client-request-id":"0751c960-828b-4887-bac2-ceed122aeebb"}}}

I have tried calling the API through Postman, Javascript and PHP (Microsoft Graph SDK for PHP) and Graph Explorer. They all return 401. The error code and message is identical to calling the Dynamics 365 Business Central API (api.businesscentral.dynamics.com/...), with invalid credentials.

What am I missing?

microsoft-graph-financials
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @Steffen-0727 Thank you for reaching out. This might happen because the user is not allowed to access financial data depending on their roles - would you check the user role and see whether they have access?

Please let me know if this helps and if you have further questions,

Diana.


0 Votes 0 ·
Steffen-0727 avatar image Steffen-0727 DianaWanjuhi-1579 ·

Thank you for your reply.

The user was an administrator with full access to everything.

I ended up calling the Business Central API directly and not using Graph. I guess I might try again when Financials moves out of beta.

0 Votes 0 ·

0 Answers