Академический Документы
Профессиональный Документы
Культура Документы
• Your choice
What
rd
Technology
• REST Development
• Any 3 party
app that uses • Web hooks
data from
Business
Central
Connect app
Can be accessed
Can be developed Included in Add-on
using specific Easy to create
by any Partner apps
endpoints
Custom API considerations
Microsoft makes sure all their APIs are consistent
Consistency of your APIs is your responsibility
https://api.businesscentral.dynamics.com/v2.0/<tenant_id>/<sandboxname>/api/waldo/killerApp/v1.0
API definition properties
Namespace properties define the endpoint hierarchy:
• Become a part of the endpoint URL APIPublisher = ‘waldo';
• These are case-insensitive! APIGroup = ‘killerApp';
APIVersion = ‘v1.0';
• Should use camelCase
https://api.businesscentral.dynamics.com/v2.0/<tenant_id>/<sandboxname>/api/waldo/killerApp/v1.0
API definition properties
Namespace properties define the endpoint hierarchy:
• Become a part of the endpoint URL APIPublisher = ‘waldo';
• These are case-insensitive! APIGroup = ‘killerApp';
APIVersion = ‘v1.0';
• Should use camelCase
https://api.businesscentral.dynamics.com/v2.0/<tenant_id>/<sandboxname>/api/waldo/killerApp/v1.0/companies(<company_id>)/crimes
Table considerations
Every entity table must provide required API fields and functionality
• All field names must be set to • SystemId value must not be changed.
camelCase explicitly. • Primary key values can be changed
• Don’t set ApplicationArea. during a modification call, and this
• It’s the Name property of a page field needs to propagate as a Rename call
that defines how the field is in AL.
referenced in REST requests and
responses.
Useful resources
https://docs.microsoft.com/en-us/dynamics-nav/fin-graph/
https://docs.microsoft.com/en-us/dynamics365/business-central/dev-
itpro/developer/devenv-connect-apps-tips
Useful Tools
Rest Client
A VSCode Extension
• Base
theAuthentication OAuth 2.0 Authentication
Client uses credentials directly • Client uses a series of REST calls
• Performs actual authentication • Performs authentication delegation
• Lower security • Higher security
• Potentially exposes user’s secrets • Does not expose user’s secrets
• Does not work in cloud production • Mandatory for all cloud production
environments. environments
Two types of authentication
Dynamics 365 Business Central APIs support two types of authentication
• Client uses the credentials directly • Client uses a series of REST calls
• Performs actual authentication • Performs authentication delegation
• Lower security • Higher security
• Potentially exposes user’s secrets • Does not expose user’s secrets
• Does not work in cloud production • Mandatory for all cloud production
environments. environments
What is OAuth 2.0
An open standard for access delegation, that allows users to grant
applications access to user information in other applications, without
exposing user credentials.
Delegation Token-based
• Connecting access
application only has • OAuth isWeb-based
REST-basedprotocol
access to an access token • Not applicable to non-HTTP
• User access is delegated to an • Access tokens are short-lived, scenarios
application issued to a specific client, and • All communication happens
• No user impersonation takes place cannot be reused through HTTP REST endpoints
• User credentials are exchanged only • Tokens are issued by an
between the user and the authorization server (Azure Active
application that “owns” the Directory) with the approval of the
credentials (in case of Business resource owner (Business Central)
Central, it’s Azure Active Directory)
• Connecting application never has
access to user’s credentials
What is OAuth 2.0
An open standard for access delegation, that allows users to grant
applications access to user information in other applications, without
exposing user credentials.
Authorization Code
Implicit Grant On-Behalf-Of
Grant
Resource Owner
Client Credentials Device Authorization
Password Credentials
Grant Grant
Grant
OAuth 2.0 is not a single thing
• There are different flows in OAuth:
Authorization Code
Grant Implicit Grant On-Behalf-Of
Resource Owner
Client Credentials Device Authorization
Password Credentials
Grant Grant
Grant
OAuth 2.0 is not a single thing
• There are different flows in OAuth:
Authorization Code
Implicit Grant
Grant On-Behalf-Of
Resource Owner
Client Credentials Device Authorization
Password Credentials
Grant Grant
Grant
OAuth 2.0 is not a single thing
• There are different flows in OAuth:
Authorization Code
Implicit Grant On-Behalf-Of
Grant
Resource Owner
Client Credentials Device Authorization
Password Credentials
Grant Grant
Grant
OAuth 2.0 is not a single thing
• There are different flows in OAuth:
Authorization Code
Implicit Grant On-Behalf-Of
Grant
Authorization Code
Implicit Grant On-Behalf-Of
Grant
Authorization Code
Implicit Grant On-Behalf-Of
Grant
Resource Owner
Client Credentials Device Authorization
Password Credentials
Grant Grant
Grant
Who owns
the token?
First party or third party First party Third party First party Third party
The application that owns the resources An authority trusted by the resource Any application that requires access to the
the user has access to, and that the user owner, that will issue access tokens on resources.
wants to delegate access to. behalf of the resource owner.
How does OAuth 2.0 work in Business Central
3. Provides credentials
Implementing OAuth 2.0 authentication
Implementing the client side of OAuth 2.0 protocol is your responsibility
Your OAuth 2.0 client must provide the described functionality
Redirect to /oauth2/authorize endpoint POST to /oauth2/token endpoint Use access token with Business Central
When user requests a Business Central Use HTTP POST method to send the Every REST request against Business Central
resource, redirect to the known endpoint. authorization code to the known endpoint API must include the token in the
Provide a callback URL that receives This is a regular REST invocation. authorization headers.
authorization code. Response contains the access token. When token expires, request refresh token.
UID: ntd2019
PWD: Antwerp.19
Get ready for the demo
UID: ntd2019
PWD: Antwerp.19
Architectural overview
Requests “like”
Tags item with
predictions
“likes” Stores
item images
Events
• OnBeforeSend Helper to call all http-
• OnAfterSend methods in the right
• ... order
Data Methods Objects Uses the REST
•Setup •Get TagsCreate •Image App
•Tags TagCreate Image •ImageReponse
•Create Image •Tag
•Create Tag Create
Image
•Create Image
•Create Image
•Predict
•Train
•...
The actual functionality
•New business logic
•New data model Uses CustomVision
•API
“Objectification”
Try to make it easy to work with the objects that needs to be sent to an
API call, and the objects you get back.
ImageClass CreateImageObject
HttpClient.Send ImageClass.SendMethod ImageObject.Send
WebResponse ImageResponseClass ImageResponse.GetId
Notifications
Don’t call us, we will call you
Notifications
• Webhooks for Business Central APIs
• Interested parties can subscribe to data changes
• Business Central sends out notifications when changes occur
https://api.businesscentral.dynamics.com/v2.0/<tenant_id>/<sandboxname>
/api/waldo/killerApp/v1.0
Notifications
• Webhooks for Business Central APIs
• Interested parties can subscribe to data changes
• Business Central sends out notifications when changes occur
https://api.businesscentral.dynamics.com/v2.0/<tenant_id>/<sandboxname>
/api/waldo/killerApp/v1.0/subscriptions
Operations on the /subscriptions endpoint
• Retrieves GET
list of existing • Creates aPOST
new • Renews PATCH
an existing • DeletesDELETE
an existing
subscriptions subscription subscription subscription
Operations on the /subscriptions endpoint
Provides subscription endpoints. A middleware component needed in case Application that requires notifications
the end-user application is a native
application or a single-page browser
application.
Create a new subscription
• Send a POST request to the /subscribe endpoint
• Handshake occurs
Sends
Callsa the
200 OK
response
notificationUrl
notificationUrl
Echoes back the
Passes
validationToken
clientSecret and
validationToken
Receiving notifications
• Business Central automatically sends notifications to notificationUrl
• bros
• bros