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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

How to use Web API to integrate with Dynamics 365 Business Central

(0) ShareShare
ReportReport
Posted on by

Hi Everyone,

I'm currently trying to integrate with Dynamics 365 Business Central use Web API in .NET Framework. However I got an "Unauthorized" error at last. 

First I followed the document "developer.microsoft.com/.../auth_register_app_v2" to get the "access-token"

7573.1.png

 1738.2.png

I have set up the "Application Secrets" and "Add a Platforms".

3438.3.png

Then, I went on "https://developer.microsoft.com/en-us/graph/docs/concepts/auth_v2_user" to get the access token. First, by sending

"login.microsoftonline.com/.../authorize

client_id=4b99370f-72ec-4347-8777-eb6faa9bb52c
&response_type=code
&scope=offline_access%20user.read%20mail.read"

I could get the code at redirectURL "http://localhost:8080/?code=OAQABAAIAAADX8GCi6Js6SK82TsD2Pb7rbbl5akjBsGP0CW4qNgqzchj_... ...A4YU1p5zYyzCAzniMPyfLFhlqxckmWByIHnq3Zs9vyZpHOaI64puPSavTzz39tlhCWNORMjIAA&session_state=74f69e17-7d57-49b4-b40d-699a47cd7351"

Then I use send a POST request to get the "access_token" and "refresh_token".

4426.4.png

Then I tried to use this access_token to authenticate the API using common endpoint https://api.businesscentral.dynamics.com/v1.0/api/beta. But it failed and return an Unauthorized message.

4834.5.png

I could only connect to Dynamic 365 via basic authentication.

8737.6.png

I don't know how to use AAD to do the authentication and connect to Dynamic 365 Business Central via common endpoint. Please help in matter and give me any advice if I have some problem in the preview steps I have provided.

Thanks in advance.

Ruining 

Categories:

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans