Dynamics 365 Finance & Operation WebAPI with POST MAN


Dynamics 365 Finance & Operation WebAPI with POSTMAN


Most of the time we used 3rd Party tools like fiddler, Post Man and SoupUI as clients to consume web services.

In this blog i will explain, How can we use POSTMAN to consume Web-API by using Oauth2 Azure Authentication.


Step-1 Download the POSTMAN from this link.

Step-2 Register The Azure Application (Web API). You can follow this link

Step-3 Add the below URL in the Reply URL section https://www.getpostman.com/oauth2/callback. check the below screenshot.



Step-4 Once App registration completed Enter Application ID in D365FO

Reference screenshot



Step-5 Open POST man and navigate to Authorization Tab and select OAuth2 as Authentication Type.

Reference screenshot



Step-6 Click on Get New Access Token. A Popup will appear.

Reference screenshot



Step-7 Fill the required fields Like below

Call Back URL > You can't change this.
Token Name (As per your requirement)
Auth URL

https://login.windows.net/YourTenant.com/oauth2/authorize?resource=https://EnvironmentURL.operations.dynamics.com

Access Token URL
https://login.windows.net/YourTenant.com/oauth2/token?resource=https://EnvironmentURL.operations.dynamics.com

You can find the tenant from AX as well. Open D365FO Click on the Setting icon. you can find it the on the top right of the screen then click on about.





Client ID > Application ID You Registered On Azure Portal
Secret Key > Enter the secret key you generate against your Azure Application.



If you don't provide a secret key then a popup window will appear for login.


Reference Screenshot


Step-8 Click on Request Toke. Within 4 to 5 seconds you will get the Azure Authentication Token.

Step-9  Now select the Header value from the drop-down and click on USE token to add this token in your request.

Reference screenshot



Step-10 Navigate to Header Tabs for the verification of the Authorization token in your request

Reference screenshot


Step-11 Enter the Complete service URL and click on send. in my case, I have called getFoo service.

Reference screenshot



Please check the above screenshot. You will find the successful result 


Please feel free to contact me if you are facing any issues during the implementation of this blog.



Delegates to customize Application startup


                            Application Startup Event Manager 



In Dynamics AX 2012, there are some customization points that allowed us to subscribe to event Applications. Startup delegate those were raised when the client was initializing.

But in D365 those events were deprecated and introduce some new events were to customize the application startup as per your requirement.

You can find those events to subscribe to in-class  ApplicationStartupEventManager  



onSystemStartup()

  • This event occurs when the system starts up and Its raised once per AOS startup.

 onFirstTimeUserInteractiveSessionCreated()

  • This event occurs when the system is creating an interactive session for the first time for a user.

 onFirstTimeUserNonInteractiveSessionCreated()

  • This event occurs when the system is creating a non-interactive session for the first time for a user.

onInteractiveSessionCreated()

  • This event occurs when an interactive session is created and ready for use.
  • It is raised once per interactive session creation for any user.

onSessionCreated(boolean _isBatch, boolean _isInteractive)

  • This event occurs when the session is created and ready for use.
  • It is raised once per interactive session creation for any user.
  • _isBatch specifies whether the system is running a batch job.
  • _isInteractive specifies whether the session is interactive.


Let's begin to verify the above delegates

To verify the delegates we will log these events into a table.

Step-1 Create a class and subscribe to the delegate in this demo I have subscribed to only two delegates.

  • onSessionCreated
  • onSystemStartup




Step-2 Create a table and insert anything to verify that events are working or not.




Step-3 Stop the IIS and Batch services.
Step-4 Build & Sync model or project.
Step-5 Verify records on the newly created table using SQL.



Step-6 Restart The IIS services.  On this step systems, startup event will raise Once.

Step-7 Start Batch service. On these steps systems startup event will raise 14 times.  You can check the number of records of SQL is 15


Step-8 Login On D365.  On this step session created event will raise.
Step-9 Verify records on newly created Table using SQL.


Please let me know if you are facing any issues during the implementation of this blog 



 

Virtual Fields Vs Computed Fields

  Virtual Field: A virtual field in D365FO is a field that doesn't have a direct representation in the database. It's a field that y...