Table of Contents

Quick Start

The root object for each service is {service}Client. For example, the root object for the Data Management service is DataManagementClient. This object contains 2 properties:

  • Api: Contains the root object for the API.
  • Helper: Contains methods that cover common scenarios combining multiple API calls.

The SDK reflects the Rest API endpoint structure. For example, the endpoint GET https://developer.api.autodesk.com/project/v1/hubs is represented by the following code:

//https://developer.api.autodesk.com / project / v1 / hubs  (GET)
                   client.DataMgtApi . Project . V1 . Hubs . GetAsync()

For more details about the SDK structure, see the Kiota documentation

Minimal example using Data Management toolkit:

public async Task<Hubs> GetHub()
{

    async Task<string> getAccessToken()
    {
        //return access token with your logic
    }

    var DMclient = new DataManagementClient(getAccessToken);

    var hubs = await DMclient.DataMgtApi.Project.V1.Hubs.GetAsync();

    return hubs;
}

Authentication

Each service needs an authentication provider. The authentication provider is passed to the client constructor as a function retrieving the access token.

The Authentication toolkit provides a set of methods to get the access token.

Minimal example using using the authentication toolkit:

public async Task<Hubs> GetHub()
{

    var APS_CLIENT_ID="abcd"; // Replace with your client id
    var APS_CLIENT_SECRET="1234"; // Replace with your client secret

    AuthenticationClient authClient = new();

    async Task<string> getAccessToken()
    {
        var token = await authClient.Helper.GetTwoLeggedToken(APS_CLIENT_ID, APS_CLIENT_SECRET, [ AuthenticationScope.DataRead]);

        return token?.AccessToken is null ? throw new InvalidOperationException() : token.AccessToken;
    }

    var DMclient = new DataManagementClient(getAccessToken);

    var hubs = await DMclient.DataMgtApi.Project.V1.Hubs.GetAsync();

    return hubs;
}

Helper methods

Most of the toolkits contain a Helper object that contains methods that cover common scenarios combining multiple API calls.

Some underlying API require multiple calls to get all values (pagination) like GET /project/v1/hubs/{hubId}/projects. For such cases, the helper methods provides 2 approaches:

  • Methods retrieving an enumerable. Which simplifies the parallelization. Relevant if you manage large datasets. Works well with await foreach or library like Reactive.io

    IAsyncEnumerable<FileVersion> GetLatestFilesVersionAsync()
    
  • Methods retrieving all values in a single call. Which are more straightforward to use. Relevant if you manage small datasets.

    Task<List<FileVersion>> GetAllLatestFilesVersionAsync()