Adsk.Platform.HttpClient
0.0.8
See the version list below for details.
dotnet add package Adsk.Platform.HttpClient --version 0.0.8
NuGet\Install-Package Adsk.Platform.HttpClient -Version 0.0.8
<PackageReference Include="Adsk.Platform.HttpClient" Version="0.0.8" />
paket add Adsk.Platform.HttpClient --version 0.0.8
#r "nuget: Adsk.Platform.HttpClient, 0.0.8"
// Install Adsk.Platform.HttpClient as a Cake Addin #addin nuget:?package=Adsk.Platform.HttpClient&version=0.0.8 // Install Adsk.Platform.HttpClient as a Cake Tool #tool nuget:?package=Adsk.Platform.HttpClient&version=0.0.8
Adsk.Platform.HttpClient
Adsk.Platform.HttpClient
is a dependency of the APS toolkit libraries, and it's used by default to make HTTP requests to the Autodesk Platform (APS) API endpoints.
Adsk.Platform.HttpClient
is a implementation of System.Net.Http.HttpClient
.
Compare to the standard System.Net.Http.HttpClient
, this implementation has the following features:
- Include automatic retry logic
- Include response payload decompression
- Error handling. Response status code 4xx and 5xx will throw an
HttpRequestException
exception
Installation
Not necessary to install separately. It's included in the APS toolkit libraries.
Usage
In the following example, we create a new instance of DataManagementClient
is based on the HttpClient
implementation.
using Autodesk.DataManagement;
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;
}
Custom HttpClient
This default httpClient
can be replaced by a custom implementation. For example, you can use the Polly
library to implement a retry policy.
using System;
using System.Net.Http;
using Microsoft.Extensions.Http;
using Microsoft.Extensions.Http.Resilience;
using Polly;
using Autodesk.DataManagement;
public async Task<Hubs> GetHub()
{
async Task<string> getAccessToken()
{
//return access token with your logic
}
// Create a custom HttpClient
var customHttpClient = CreateHttpClient();
//Pass it to the DataManagementClient
var DMclient = new DataManagementClient(getAccessToken, customHttpClient);
var hubs = await DMclient.DataMgtApi.Project.V1.Hubs.GetAsync();
return hubs;
}
private HttpClient CreateHttpClient() {
var retryPipeline = new ResiliencePipelineBuilder<HttpResponseMessage>()
.AddRetry(new HttpRetryStrategyOptions
{
BackoffType = DelayBackoffType.Exponential,
MaxRetryAttempts = 3
})
.Build();
var socketHandler = new SocketsHttpHandler
{
PooledConnectionLifetime = TimeSpan.FromMinutes(15)
};
var resilienceHandler = new ResilienceHandler(retryPipeline)
{
InnerHandler = socketHandler,
};
return new HttpClient(resilienceHandler);
}
Error Handling
Response status code 4xx and 5xx will throw an HttpRequestException
exception. The exception message will contain the response status code and the endpoint response content as a `string``.
using Autodesk.DataManagement;
public async Task<Hubs> GetHub()
{
async Task<string> getAccessToken()
{
//return access token with your logic
}
var DMclient = new DataManagementClient(getAccessToken);
try {
var hubs = await DMclient.DataMgtApi.Project.V1.Hubs.GetAsync();
return hubs;
} catch (HttpRequestException ex) {
Console.WriteLine(ex.StatusCode);
Console.WriteLine(ex.Message); //Response content returned by the API endpoint
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.Kiota.Http.HttpClientLibrary (>= 1.4.0)
NuGet packages (9)
Showing the top 5 NuGet packages that depend on Adsk.Platform.HttpClient:
Package | Downloads |
---|---|
Adsk.Platform.ACC.AccountAdmin
Autodesk Platform: ACC Account service SDK and tools |
|
Adsk.Platform.DataManagement
Autodesk Platform: Data Management Service SDK and tools |
|
Adsk.Platform.ACC.CostManagement
Autodesk Platform: ACC Cost Service SDK and tools |
|
Adsk.Platform.ACC.ModelProperties
Autodesk Platform: ACC Model Properties Service SDK and tools |
|
Adsk.Platform.Authentication
Autodesk Platform: Authentication Service SDK and tools |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.1.3 | 139 | 10/17/2024 |
0.1.2 | 133 | 10/16/2024 |
0.1.1 | 133 | 10/16/2024 |
0.1.0 | 138 | 10/16/2024 |
0.0.16 | 134 | 10/14/2024 |
0.0.15 | 123 | 10/14/2024 |
0.0.14 | 139 | 10/14/2024 |
0.0.13 | 210 | 9/18/2024 |
0.0.12 | 184 | 7/30/2024 |
0.0.11 | 149 | 7/16/2024 |
0.0.10 | 148 | 7/16/2024 |
0.0.9 | 145 | 5/31/2024 |
0.0.8 | 159 | 5/22/2024 |
0.0.7 | 119 | 5/14/2024 |
0.0.6 | 173 | 5/4/2024 |
0.0.5 | 141 | 5/3/2024 |
0.0.4 | 164 | 4/30/2024 |
0.0.3 | 172 | 4/30/2024 |