How it works...

To describe this, it is best to step through the key parts of the code.

The first part was clicking on save on the ODataClient.tt file. This created the class by reading the URL we entered in the metadataDocumentURI variable. When the file is saved, it triggers the generation of code using metadata from Dynamics 365 for Operations. If you click on Save, and then cancel the security warning, the ODataClient.cs file will be emptied.

Within the code we wrote, the first key part is the authentication, which works by authenticating with Azure AD and fetching an authentication, which is used with each submission request. The authorization code was determined in the GetAuthorization method.

The log on URI is always https://login.windows.net/ ...

Get Extending Microsoft Dynamics 365 for Operations Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.