Rui Jarimba
Rui Jarimba

Reputation: 18169

How to specify the API version?

According to the Azure DevOps Services REST API Reference, the request URI has the following format:

https://{instance}[/{team-project}]/_apis[/{area}]/{resource}?api-version={version}

Regarding the api-version:

Every API request should include an api-version to avoid having your app or service break as APIs evolve.

I started using the .NET client libraries for Azure DevOps Services (and TFS) to manage dashboards programmatically.

I am able to connect to Azure DevOps using a Personal Access Token:

var credential = new VssBasicCredential(string.Empty, "PersonalAccessToken");

using (VssConnection connection = new VssConnection(new Uri("...."), credential))
using (var client = connection.GetClient<DashboardHttpClient>())
{
     // ...
}

How can I specify the API version? Does it still make sense to do it, when using the .NET client libraries?

Upvotes: 2

Views: 754

Answers (1)

user247702
user247702

Reputation: 24232

The API version is decided by the client libraries. You can confirm this by disassembling them (e.g. using ILSpy).

For example, in the current stable release of Microsoft.TeamFoundationServer.Client, DashboardHttpClientBase has a CreateDashboardAsnc method that makes the following call:

this.SendAsync<Dashboard>(..., new ApiResourceVersion("4.1-preview.2"), ...);

Upvotes: 1

Related Questions