D365 – Play with Headless Commerce

Headless Commerce is a set of API’s, that allows you to interact with the Commerce Scale Unit, that is the main component when working with POS and eCommerce.  But as shown by Patrick Mouwen’s blog, it can be used for so much more.

But the purpose of this blogpost, is to give you a low-entry start on how you can play with it through a browser and using postman or insomnia.

First we need a site to play with.  Let’s use https://www.adventure-works.com/ and open a product, like this : https://www.adventure-works.com/cozmino-men-s-coat/68719519883.p

If you press “F12” you should be able to see a lot of calls towards the headless Commerce.  And got to the network tab, and then filter on the “Fetch/XHR”.  See if you can find the call “GetByIDs”, then take a look at the preview/payload and the response to see what you can get out of the API.

The GetByIDs is documented as a API here : https://learn.microsoft.com/en-us/dynamics365/commerce/dev-itpro/retail-server-customer-consumer-api, and you can find additional 493 distinct APIs.

Here we see that GetByIDs returns product information in the documentation.

The next step, is to take this a bit further.  Right click on the name, and copy as cURL (bash)

Then you can paste the entire call with headers and authenication.  In this example, I’m using Insomnia, but it works just as great using Postman.

You now have an interface, where you can test out the results from the headless call, and see the returned data.

This is also great, because all headers and authentication is copied also, so you can get data associated with the login and the role when logged in.

So the quick summary : copy as cURL (bash), then paste into postman/insomnia.

Now you have learned the first step on how to play with headless commerce.

Your next step is to read Patrick Mouwen’s blog : https://patrickmouwen.com/ , and the start building 3’rd party apps that can use more of the API’s provided by the Dynamics 365 eCommerce.

And if you want a complete set of documentation you can ask Microsoft nicely through a support case to enable swagger for a non-prod environment.