Skip to content
Go back

D365 - Using API Testing Tools to Access CRM

Table of contents

Open Table of contents

Introduction

I usually use API testing tools like Postman and Apifox to test web services, which makes it convenient to debug interfaces. Dynamics 365 also provides many standard interfaces.

Today, I will try to connect to Dynamics 365 using Apifox and attempt to use the standard interfaces.

Prerequisites

  1. You are an “Administrator” user, otherwise you cannot access the Azure Active Directory portal.
  2. Have API testing tools installed, such as Postman, Apifox, etc.

Detailed Steps

Get ClientId and ClientSecret

Step 1. Register an Application

(1) Visit and log in to the Azure Portal.

(2) In the search box at the top, search for “App registrations” and click on it. Register Application-01

(3) Click on “New registration.” Register Application-02

(4) On the pop-up page, enter a meaningful application name (e.g., D365-GetClientSecret) -> Select supported account types -> Click the “Register” button. Register Application-03

Step 2. Get ClientId

ClientSecret is a password-like key that can effectively prevent unauthorized access. Compared to using usernames and passwords, ClientSecret can provide a more secure authentication method, reducing the risk of data leakage.

After completing Step 1, we can find the Application ID (ClientId) from the “Overview” section and copy it to Notepad for later use.

Get ClientId

Configure Application for ①Authentication, ②Manifest, ③API Permissions

Step 1. Add Authentication

Authentication -> [+ Add a platform] -> Select Web Add Authentication-01

Enter http://localhost -> Check “Access tokens (used for implicit flow)” Add Authentication-02

Step 2. Modify “Manifest” Configuration File

Set the following 2 properties to true and save.

  1. AllowPublicClient
  2. oauth2AllowImplicitFlow

Modify "Manifest" Configuration File

Step 3. Add API Permissions

(1) API Permissions settings -> ”+ Add a permission” Add API Permissions-01

(2) “APIs my organization uses” -> Search for Dataverse -> Select Dataverse Add API Permissions-02

If you can find Dynamics CRM in the Microsoft API, select Dynamics CRM. If not, follow the steps above and select Dataverse.
Add API Permissions-03

(3) Select delegated permissions -> Check permissions -> Add permissions Add API Permissions-04

Postman Connection Testing

(1) Create a new Collection and give it a meaningful name, e.g., using-postman-call-crm Create Postman Collection

(2) Create an Environment Create Postman Environment

(3) Add environment variables

#VariableDescription/Example
1urlYour CRM environment URL
2clientidClientId of your application, as Geted in “Step 2. Get ClientId”
3version9.0
4webapiurl{{url}}/api/data/v{{version}}/
5callbackhttp://localhost
6authurlhttps://login.partner.microsoftonline.cn/common/oauth2/authorize?resource={{url}}

If you are using the Global version, use https://login.microsoftonline.com/common/oauth2/authorize?resource={{url}} for the authurl variable.

Add Environment Variables in Postman

(4) Create a new request Create Postman Request

(6) Configure getting Token information for the request:

Configure Token Information for Postman Request

Clicking on Get New Access Token will prompt a login box. Fill in your account and password to Get the Token information.

Get Token in Postman

The End

Copyright Notice

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the source, use non-commercially, and maintain the same license.


Share this post on:

Previous Post
D365 - Add Colors to OptionSet Fields
Next Post
D365 - Exporting Reports as PDF Introduction