A quickstart to the Dataverse Web API

This sample shows how to authenticate with the Microsoft Dataverse web service and invoke a Dataverse Web API. The sample uses the Microsoft Authentication Library (MSAL) for web service authentication, and invokes the Web API function WhoAmI.

Learn more in Quick Start: Web API sample (C#).

How to run this sample

  1. Download or clone the repo so that you have a local copy.
  2. Open the solution (.sln) file in Visual Studio 2022 or later (requires .NET 10 SDK).
  3. Edit line 19 of Program.cs to set the URL for your Dataverse test environment.
    string resource = "https://<env-name>.api.<region>.dynamics.com";
  4. Press F5 to run the sample.
  5. You're prompted to choose a valid Dataverse user and enter your password.
  6. When the sample is finished, press any key to exit.

What this sample does

This sample returns the UserId value of the logged on user by invoking the WhoAmI unbound Web API function.

How this sample works

This program makes use of a clientID and redirectUri shared by all Web API samples.

Setup

This sample doesn't require any setup other than specifying the test environment URL.

Demonstrates

  • Microsoft Authentication Library (MSAL) for service authentication
  • Web client configuration
  • Web API unbound function invocation and web service response parsing

Clean up

This sample doesn't require any clean up, since it doesn't create any Dataverse table rows.