In this blog post, we’re going to take a look at a tool we can utilise to make working with the Dataverse Web API loads easier! Similar to Graph Explorer, but for a number of API’s, Postman is a tool that lets you authenticate to your Microsoft Dataverse environments, then providing the ability to create and send requests to the endpoint, which return the responses within the Postman UI.
Using tools like Postman are a great way to discover capabilities of an API such at the Dataverse Web API. In this post, we will configure a Postman environment ready for working with one of our Dataverse environments.
Download the desktop application
So first, you’ll want to make sure you’ve got a Postman account and you’ve downloaded and installed the desktop application to work with.
You can get the desktop application for Postman here – Download Postman | Get Started for Free
Once you’re signed into the Postman desktop application, head to your workspace, or a workspace you’d like to use for working with Dataverse in, then in the left hand pane, select Environments.
Then select the plus just below the workspace name to create an environment.
Now we need to grab some details from our Power Platform environment. Head to make.powerapps.com and navigate to the environment you want to make a connection with. We’ll get the base url of the Web API endpoint from the developer resources in our environment.
Once you’re in your environment at make.powerapps.com select the settings icon in the top right hand corner of your screen and then select developer resources.
Copy the base URL under Web API endpoint. Your endpoint will follow a structure like this…
Now back in postman you’ll want to create a new variable called url, then paste the endpoint url as the initial value. Like this…
Then you want to do the same thing creating further variables using the following names and values.
With updates to the Web API for dynamics 365 these values may change slightly. You can refer to the learn page here for the latest values in case they’ve been updated…
Once you’ve got your variables added, select save in postman to create your new environment.
Now, select your newly created environment in Postman with the environment switcher near the top right hand corner of the application.
Now we need to create an access token to be able to authenticate using OAuth 2.0
Now select the plus next to your environment tab which will open a screen to allow you to start creating requests against the API. Select the authorization tab and we will get to work configuring a token.
Select the authorization type as OAuth 2.0
Then choose to add authorization data to the request headers when making a call to the API.
Now scroll down to the point where it says ‘Configure new token’.
Give your token a name of your choice to start with, then copy the following values for the rest of the corresponding fields.
Here we are referencing the variables we created in this environment a moment ago. It’s key to note the client ID we’re using here is of an application registered by Microsoft for all Dataverse environments so that we don’t have to create ones in our own tenants.
Following that select Get New Access Token.
If you’ve previously done this using different credentials to the ones you want to use to create this token select Clear cookies to clear the credentials Postman currently has cached. This will have you sign in using Azure Active Directory. Those will be the credentials cached if you have recently done this in Postman using other creds to the ones you wish to use to create this access token.
Sign in using AAD when requested.
Following this you should see a dialogue to say authentication was successful, then you will get a token appear. Select Use Token to continue.
Now, you should be able to work with the Dynamics API in Postman making requests in the same tab you’ve got a current token available for. You’ll need to refresh this token and get a new one every hour as they expire on an hourly basis.