open bi REST client
BiExcellence.OpenBi.Api.Client is the .NET client for the REST API of open bi server. It runs on
netstandard2.0 and later - Windows, Linux, macOS, mobile and Blazor WebAssembly - and is trimming and AOT
compatible on .NET 8 and later.
It replaces the BiExcellence.OpenBi.Api.* packages, which talk to the legacy command API. See
Migrating from the command API client.
Getting started
Add the package reference to your project:
<PackageReference Include="BiExcellence.OpenBi.Api.Client" Version="*" />
Create a client for the server's REST API base address, which is /openbi/api/ on any port of the server, and
log in:
using BiExcellence.OpenBi.Api;
using BiExcellence.OpenBi.Api.Auth;
using BiExcellence.OpenBi.Api.Users;
using var client = new OpenBiApiClient(new Uri("https://myserver/openbi/api/"));
await client.LoginAsync("username", "password", cancellationToken);
var me = await client.GetCurrentUserInfoAsync(cancellationToken);
var users = await client.GetUsersAsync(
OpenBiListRequest.Create().Filter("lastname eq 'Smith'").OrderBy("firstname").Top(50).IncludeTotalCount(),
cancellationToken);
Console.WriteLine($"{users.Count} of {users.TotalCount} users");
The client is OpenBiApiClient. Every call is an extension method on
IOpenBiApiClient, grouped by area into one namespace each - a using for the
namespace is what makes its calls available:
Using an HttpClient of your own
The client can wrap an existing HttpClient, for example one from IHttpClientFactory. Its BaseAddress
has to be set:
services.AddHttpClient("openbi", c => c.BaseAddress = new Uri("https://myserver/openbi/api/"));
// later
var client = new OpenBiApiClient(httpClientFactory.CreateClient("openbi"));
It does not dispose that HttpClient unless it is told to (disposeHttpClient: true).
Next steps
- Authentication - the ways to get a token, and keeping it fresh
- Lists - filtering, sorting and paging list endpoints
- Errors - what a failed call throws
- DataProviders - opening, changing and reading a report
- API reference - every type and method