InfoApi
.NET SDK: the Info operations, 1 method, each with its parameters, result and a complete example.
.NET SDK · BIMworks.Sdk.Api · class · 1 method
General information about the instance
Construct it with the client of the connect step: client.GetRequiredService<IInfoApi>(). Each method is one operation of the API part, where it runs on its page.
| Method | Operation | Description |
|---|---|---|
GetApplicationVersionAsync | GetApplicationVersion | The BIM.works version of the instance |
GetApplicationVersionAsync#
.NET#
Task<IGetApplicationVersionApiResponse> GetApplicationVersionAsync(CancellationToken cancellationToken = default)The BIM.works version of the instance. The version of BIM.works the instance runs, to check compatibility. No credential needed.
| Operation | GetApplicationVersion · POST /openapi/info/GetApplicationVersion |
|---|---|
| Scope | none: callable before logging in |
Parameters#
None: the operation takes no request.
Returns#
GetApplicationVersion200Response — The version
Example#
.NET#
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;
// 1. Connect to BIM.works (GetApplicationVersion needs no login)
IServiceProvider Connect(string bearer)
{
var services = new ServiceCollection();
services.AddApi(options =>
{
options.AddTokens(new BearerToken(bearer));
options.AddApiHttpClients(http =>
{
http.BaseAddress = new Uri("https://bim.works" + "/openapi");
http.Timeout = Timeout.InfiniteTimeSpan;
});
});
return services.BuildServiceProvider();
}
var client = Connect("");
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;
// 2. The request
// (GetApplicationVersion takes no request)
// 3. The call
var response = await client.GetRequiredService<IInfoApi>().GetApplicationVersionAsync();
// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));