DEV Community

Cover image for Interact with ADT using Postman
Yongchang He
Yongchang He

Posted on

Interact with ADT using Postman

ADT: Azure Digital Twins

Postman is a REST testing tool that provides key HTTP request functionalities in a desktop and plugin-based GUI. You can craft HTTP requests and submit them to the Azure Digital Twins (ADT) REST APIs.

This blog describes how to configure the Postman REST client to interact with the ADT APIs (creating a request collection).

Prerequisites

Table of content

Using Azure CLI
Using Postman
Create your own ADT collection
Add an individual request
Set request details

Getting Started

Using Azure CLI

Image description

1. Run the following command to access Azure credentials:

az login
Enter fullscreen mode Exit fullscreen mode

2. Run the following command to get a bearer token with access to the ADT service.

using data plane APIs:

az account get-access-token --resource 0b07f429-9f4b-4714-9392-cc5e8e80c8b0
Enter fullscreen mode Exit fullscreen mode

using control plane APIs:

az account get-access-token --resource https://management.azure.com/
Enter fullscreen mode Exit fullscreen mode

result example:
"accessToken": "eyJ0eXAiOiJ..."
"expiresOn": "2022-07-2...",
"subscription": "907b0d06-a...",
"tenant": "24ab6cd0-487e-...",
"tokenType": "Bearer"

Save the value of the accessToken and we will use it later on.

Using Postman

We can either create our own collection of ADT APIs or import an existing one. This article will be talking about creating one from scratch.

Create your own ADT collection

  1. In My Workspace click new to create a new Collection in Building Blocks. Change the collection name if you like.

  2. In the Authorization tag, set the Type to OAuth2.0 and paste your access token into the Token box. Click save.

Add an individual request

  1. In My Workspace click new to create a new Request in Building Blocks.

  2. By clicking the Save button, you can name the new request and select a collection to save it. Click save again.

The new request Query twins was saved in ADT Custom Collection directory.

Image description

Set request details

Change the type from GET to POST, and paste the URL below:

https://digitaltwins-host-name/query?api-version=2020-10-31.
Enter fullscreen mode Exit fullscreen mode

Using your own digital-twins-host-name

In the Authorization tab, set the Type to Inherit auth from parent.

Check that the body shown for the request in the Body tab matches the needs described below:

Image description

Use send button to send the request.

Image description

OK! All set.

References

https://docs.microsoft.com/en-us/azure/digital-twins/how-to-use-postman?tabs=data-plane
Cover image from this link
https://aithority.com/computing/5-exciting-applications-of-digital-twin-technology/

Top comments (0)