Connecting Postman with Dynamics 365

This is a pretty straightforward setup. Postman can be called a browser on steroid – it can send HTTP request to our D365 instance and get the result. To set it up, you need to consider 3 areas in Postman.

  1. Environment
  2. Collection
  3. Request

We will start with each one of them in sequence.

Create Environment with Below Variables:

Environment can be used mainly to store dependent variables – so we can have one set for Prod and another for Test.

VariableValue
urlhttps://<orgname&gt;.crm.dynamics.com
clientidclientId Guid From App Registration
version9.1
callbackRedirect URI from App Registration
authurlhttps://login.microsoftonline.com/common/oauth2/authorize?resource={{url}}
webapiurl{{url}}/api/data/v{{version}}/

Create Collection and Auth Token

Collection contain multiple Request objects. You can have authorization at Collection level which can then be used for its Request.

Select the ‘Collection’ from left menu and click on ‘+’ to create new collection

Now under Auth Tab select ‘OAuth 2.0’ as option and below settings:

Once you click on ‘Gent New Access Token’ you will receive it as below:

Create Request

The last step is to create Request. Request have the HTTP verb and the URL. The authentication mechanism can also be defined explicitly here.

Right click on collection and create request:

  • Name the request like above ‘WhoAmI Request’
  • Put the send url as {{webapiurl}}WhoAmI
  • Select the access Token as the one saved before.

Environment Variable – Power Platform

Environment variable enable us to package the configuration along with customization in a single solution. This help us in eliminating the custom entity we use to create in Dynamics which were environment dependent like Url/ email address/ Integration points etc.

Lets do step-by-step process to create and migrate configuration.

We will start by creating one solution and adding Environment Variable to it.

We will create two EV

  1. CurrentUrl
  2. SenderEmail

Both these variable are usually environment dependent. While the URL denotes the D365 instance, the email can be sender email address for which mailbox is configured. We can keep the type as Number/Text/JSON/Data Source. We will stick with Text type only.

The CurrentUrl variable is neither having Default Value nor Current Value.

The SenderEmail variable is having current value but no default value.

These two are important field which we need to pay attention to. Once created, we will export and import the solution.

We are importing managed solution – unmanaged is straight forward.

You will see a Flyout option asking for value of CurrentUrl. If you remember, we didn’t provide value for this in source environment and that is why we need to provide value before importing the solution. But if you have already given the current or default value in source then the flyout menu will NOT appear.

Once imported, if you open the solution then it will not be editable. This is a product behavior (bug?) where it doesn’t allow you to update the config value in the managed solution. If it was unmanaged then it would have been editable.

Now to edit the value, you need to modify the default solution. This can be done by going directly to the table menu or going to default solution or even in advanced find.

Other option is to modify the solution zip file – but lets skip that.

Do remember that environment variable is nothing but two table(entities) in Dataverse (Dynamics 365). The two tables are :

  1. Environment Variable Definition
  2. Environment Variable Value

These two table are 1:N with plugin enforcing 1:1 relationship.

So if you try to add more than one Environment Variable Value for a Definition, you will get an error.

In Power Automate, you will see the Environment Variable under the section as shown below.

In Canvas App, if you are using it as Data Source then you can go to Setting and enable the checkbox.

Otherwise, You can read the Environment Variable just like any other table.

Then you can read the variable just like any row in Dataverse

Set(myVariable, LookUp(
    'Environment Variable Values',
    'Environment Variable Definition'.'Schema Name' = "test_CurrentUrl",
    Value)
);

%d bloggers like this: