Skip to main content

Making a call to Retail Server APIs

This article will talk about how to make a call to Retail APIs(non anonymousand what all information is required to get the response.

I started by generating the access token using username-password flow and obviously the client id as shown in below image:

Then I tried to make a call to an API using Postman as shown below:

And here is the 401 Unauthorized error ☹ and the reason is - Microsoft_Dynamics_Commerce_Runtime_DeviceTokenNotPresent

After spending hours, I got to know that Retail APIs can’t be called just by passing the access token. In order to make API call successful, there is one additional information ‘devicetoken’, which needs to be sent. 

Now where to pass this information?

Well, fortunately I was able to figure it out. This devicetoken has to be passed as an header while making API call as shown below:

Once device token is passed, I received the expected response from the API. 

Hope I saved your hours. Enjoy troubleshooting!