About This Page
This page is part of the Azure documentation. It contains code examples and configuration instructions for working with Azure services.
Bias Analysis
Bias Types:
⚠️
windows_first
⚠️
missing_linux_example
⚠️
windows_tools
Summary:
The documentation is heavily focused on Visual Studio, a Windows-centric tool, and does not mention or provide examples for equivalent workflows on Linux or macOS. All setup and usage instructions are tailored to Visual Studio and its .http file support, with no mention of cross-platform alternatives such as VS Code with REST Client, curl, Postman, or other tools commonly used on Linux. The prerequisites and step-by-step instructions assume a Windows environment, and there are no Linux-specific notes or parity guidance.
Recommendations:
- Add a section describing how to perform the same API calls using cross-platform tools such as VS Code with the REST Client extension, curl, or Postman.
- Include Linux/macOS-specific setup instructions and screenshots where applicable.
- Clearly indicate that Visual Studio is Windows-only and suggest alternatives for non-Windows users.
- Reorganize the documentation to present cross-platform options before or alongside Windows-specific instructions.
- Provide sample .http files and equivalent curl/Postman requests for Linux users.
Create pull request
Flagged Code Snippets
Your variables should now look something like this:
:::image type="content" source="media/how-to-use-apis/variables-token-control.png" alt-text="Screenshot of the control plane variables, including a token." lightbox="media/how-to-use-apis/variables-token-control.png":::
---
## Add requests
Now that your `.http` file is set up, you can add requests to the Azure Digital Twin APIs.
Start by opening the [Azure Digital Twins REST API reference](/rest/api/azure-digitaltwins/). This documentation contains details of all the operations covered by the APIs. Navigate to the reference page of the request you want to run.
This article uses the [DigitalTwins Update API](/rest/api/digital-twins/dataplane/twins/digital-twins-update) from the data plane as an example.
1. **Add request template**: Copy the HTTP request shown in the reference documentation.
:::image type="content" source="media/how-to-use-apis/copy-request.png" alt-text="Screenshot of the HTTP request in the Digital Twins API documentation." lightbox="media/how-to-use-apis/copy-request.png":::
In Visual Studio, paste the request in a new line below the variables in your `.http` file.
1. **Add parameters**: Look at the **URI Parameters** section of the reference documentation to see which parameter values are needed by the request. You can replace some with the [variables](#add-variables) you created earlier, and fill in other parameter values as appropriate. To reference a variable, put the variable name in double curly braces, like `{{variable}}`. For more information, see [Variables](/aspnet/core/test/http-files#variables).
>[!NOTE]
>For data plane requests, `digitaltwins-hostname` is also a parameter. Replace this parameter value with `{{hostName}}` to use the value of your host name variable.
Here's how this step looks in an example request:
:::image type="content" source="media/how-to-use-apis/add-parameters.png" alt-text="Screenshot of the request with parameters in Visual Studio." lightbox="media/how-to-use-apis/add-parameters.png":::
1. **Add authorization**: To specify authentication with your bearer token variable, add the following line (exactly as written) directly underneath the request.
---
>[!NOTE]
> If you need to access your Azure Digital Twins instance using a service principal or user account that belongs to a different Microsoft Entra tenant from the instance, you need to request a token from the Azure Digital Twins instance's "home" tenant. For more information on this process, see [Write app authentication code](how-to-authenticate-client.md#authenticate-across-tenants).
3. Copy the value of `accessToken` in the result. This value is your **token value** that you paste into Visual Studio to authorize your requests.
:::image type="content" source="media/how-to-use-apis/console-access-token.png" alt-text="Screenshot of the console showing the result of the az account get-access-token command. The accessToken field with a sample value is highlighted." lightbox="media/how-to-use-apis/console-access-token.png":::
>[!TIP]
>This token is valid for at least five minutes and a maximum of 60 minutes. If you run out of time allotted for the current token, you can repeat the steps in this section to get a new one.
### Add token to `.http` file
In your `.http` file in Visual Studio, add another variable that holds the value of your token.
# [Data plane](#tab/data-plane)