Use OData with Postman Dynamics 365 Finance and Operations (On-Premises)

This is a brief example of how to use Postman on On-Premises environments and perform OData queries.

ADFS Setup

Now on ADFS server in my on-prem environment, I need to add a client application. From “AD FS Management” I see Application Groups, open the default application group for Dynamics 365 called “Microsoft Dynamics 365 for Operations On-Premises”, it will look something similar to this:

Put the AX URL as a Redirect URI without your «namespace/AXSF»

Copy the Client Identifier and the secret, you must need this information to setup the Active Azure Active Directory parameters

You must authorize the new server application to use the Web API and request OpenID connection authorizations

After complete this setup, its necessary  configure the Azure Active Directory applications

System administration –>  Setup –> Azure Active Directory applications

And use the previously Client ID generated in the ADFS application.

Postman configuration

Create a new environment with the following parameters

VariableValue
tenant_idadfs
client_id«CLIENTID GENERATED IN THE ADFS APP»
client_secret«SECRET GENERATED IN ADFS»
resourceYour AOS URL i.e  «https://ax.d365ffo.onprem.contoso.com«
grant_typeclient_credentials

Create a first collation to request the authentication token

In the body, set the reference to the global variables defined in the environment configuration

KeyValue
tenant_id{{tenant_id}}
client_id{{client_id}}
client_secret{{client_secret}}
resource{{resource}}
grant_type{{grant_type}}

Copy the following script in Test

var json = JSON.parse(responseBody);

tests[«Get Azure AD Token»] = !json.error && responseBody !== » && responseBody !== ‘{}’ && json.access_token !== »;

postman.setEnvironmentVariable(«bearerToken», json.access_token);

To test if everything is ok, you can click on Send and the bearer token is generated

KeyValue
Content-Typeapplication/x-www-form-urlencoded

You can get data for any entity, you only need set the following parameter in the Get

TypeOdata URL
Get{{resource}}/namespaces/AXSF/data/CustomersV3?$top=5

Header Parameters

KeyValue
AuthorizationBearer {{bearerToken}}
Content-Typeapplication/json

You can perform a test and the entity return the requested data.

Deja un comentario