This library allows you to connect to the CxReports API from your applications.
dotnet add package CxReports.ApiClient
First, register the ICxReportsApiClient
service at stratup:
serviceCollection.AddCxReportsApiClient(configuration);
Then, resolve the ICxReportsApiClient
or inject it into your class:
var cxReports = serviceProvider.GetRequiredService<ICxReportsClient>();
Now you can interact with the CxReports API:
// list all reports for the default workspace
var reports = await cxReports.GetReportsAsync();
// list all workspaces
var workspaces = await cxReports.GetWorkspacesAsync();
// download a PDF report
var pdfResponse = await cxReports.DownloadPdfAsync(new() {
Report = new() { TypeCode = "invoice" }
});
using var stream = await pdfResponse.Content.ReadAsStreamAsync();
using var output = File.Create("invoice.pdf");
stream.CopyTo(output);
The ConsolePlay
project provides the usage examples.
To set up your access variables:
- Copy the
appSettings.json.sample
file toappSettings.json
. - Open the file in your text editor.
- Replace the placeholder values with your actual values.