Landax.Client
2.2.2
dotnet add package Landax.Client --version 2.2.2
NuGet\Install-Package Landax.Client -Version 2.2.2
<PackageReference Include="Landax.Client" Version="2.2.2" />
<PackageVersion Include="Landax.Client" Version="2.2.2" />
<PackageReference Include="Landax.Client" />
paket add Landax.Client --version 2.2.2
#r "nuget: Landax.Client, 2.2.2"
#:package Landax.Client@2.2.2
#addin nuget:?package=Landax.Client&version=2.2.2
#tool nuget:?package=Landax.Client&version=2.2.2
Landax.Client
This documentation is about the helper client for the Landax API.
The client uses the OData compliant version of the API. There are more endpoints available in the API then are exposed in this Client.
For more information, see API documentation in Landax at Controlpanel → API.
Configuration
The configuration settings for the client are following:
- Host: The host of the API, normally "*.landax.no"
- ApplicationKey / ClientKey: Used to identify and authenticate the integration. This can be generated in Landax, at Controlpanel → API.
- UseSsl: If a secure connection should be used. Normally and default
true
, set to false for local connections not supporting SSL.
Configuration in XML
You can configure the client by an external XML file. The client configuration can be a part of a bigger XML configuration if you want, but have to look like this.
<Landax.Client>
<Configuration>
<Host>tenantalias.landax.no</Host>
<UseSsl>True</UseSsl>
<ApplicationKey>aaaa-aa-aaaa-aaa</ApplicationKey>
<ClientKey>aaaa-aa-aaaa-aaa</ClientKey>
</Configuration>
</Landax.Client>
The code (C#)
using Landax.Client;
//-----
// in the code
var xmlFile = new FileInfo(@"C:\path\to\file.xml");
var config = new Config(xmlFile);
var client = new Client(config);
Configuration in code
You can just code the configuration right in the application code.
var config = new Config
{
Host = "tenantalias.landax.no",
ApplicationKey = "aaaa-aa-aaaa-aaa",
ClientKey = "aaaa-aa-aaaa-aaa",
UseSsl = true,
};
var client = new Client(config);
Authentication
After creating a Client object following the guide above, you can connect and authenticate with the API. The following methods are all async methods and must be awaited. The order of the methods are quite important.
First, we'll connect to the correct host.
await client.Connect();
After connecting, we'll have to authenticate using username and password. We recommend using an API user with limited permissions.
await client.Login("username", "password");
A complete setup code for a working client in an async context may be like this.
var config = new Configuration.Config
{
Host = "*.landax.no",
ApplicationKey = "aaaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
ClientKey = " aaaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
UseSsl = true,
};
var client = new Client(config);
await client.Connect();
await client.Login("username", "password")
Querying the API
After the Client has successfully connected, the connection is available as the
Data
property on the Client. The Data
is following normal Entities
design, like an Entity Framework Entities
class or OData Client class.
We have also made some services and methods on the Data object, for API functions that are not a part of OData. There are still more endpoints available which is not part of this client.
Code Samples
Receiving data from API
// iterator with all incidents from the API
var incidents = client.Data.Incidents;
// get all closed incidents, using lambda
var closedIncidents = client.Data.Incidents
.Where(i => i.ClosedDate < DateTime.Now);
// get my projects
var currentUserId = await client.Data.GetCurrentUserId();
var myProjects = await client.Data.Projects
.Where(p => p.ResponsibleCoworkerId == currentUserId);
// support LINQ as well
var myClosedProjects =
from project in client.Data.Projects
where project.ResponsibleCoworkerId == currentUserId &&
project.EndDate < DateTime.Now
select new { project.Name, project.EndDate };
Inserting data
var project = new Project();
project.Name = "Main project";
project.StartDate = DateTime.Now;
project.EndDate = DateTime.Now.AddDays(14);
project.ResponsibleCoworkerId = await client.Data.GetCurrentUserId();
client.Data.AddToProjects(project);
client.Data.SaveChanges();
Modify data
var currentUserId = await client.Data.GetCurrentUserId();
var projects = client.Data.Projects
.Where(p => p.ResponsibleCoworkerId != currentUserId);
foreach(var project in projects)
{
project.ResponsibleCoworkerId = currentUserId;
project.Name = "This project is now mine!";
client.Data.UpdateObject(project);
}
client.Data.SaveChanges();
Call API method: Create project from template
var templateProject = client.Data.Projects
.Where(p => p.IsTemplate == true)
.FirstOrDefault();
if(templateProject != null) {
var project = await client.Data.ProjectService.CreateFromTemplate(templateProject.Id);
}
Changelog
2.2.2
- Minor fixes
2.2.0
- Added Landax specific exceptions when saving data
- Added global exception handler: builder.Services.AddLandaxExceptionHandler()
2.1.4
- Updated .NET dependencies/packages
- Updated API version to use v30
- Included more examples
2.1.3
- Updated documentation
- Added support for running search queries
- Added support for connecting via an existing access token
2.1.2
- Update API version to 29 and change namespace of generated code.
2.0.1
- Remove the "Database" concept from configuration, use only "Host".
2.0.0
- Support for .NET 9 and C# 14 (earlier was only for .NET Framework 4.6)
1.3.3
- Added CreateDocument function that accepts a stream
1.3.1
- Fixed return type from CreateDocument
1.3.0
- Fixed error handling in CreateDocument
- Fixed CreateDocument endpoint
- Updated to API version 21
1.2.0
- Updated API version to version 18 - to get the newest data model changes.
1.1.0
- Added support for CustomData
- Changed CreateDocument method
1.0.0
- Initial version, using OData libraries to connect to the API.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Microsoft.AspNetCore.Diagnostics.Abstractions (>= 2.3.0)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.0)
- Microsoft.AspNetCore.OpenApi (>= 9.0.6)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.7)
- Microsoft.OData.Client (>= 7.8.3)
- Microsoft.OData.Core (>= 7.8.3)
- Microsoft.OData.Edm (>= 7.8.3)
- Microsoft.Spatial (>= 7.8.3)
- Newtonsoft.Json (>= 13.0.1)
- System.ComponentModel.Annotations (>= 5.0.0)
- System.Text.Json (>= 9.0.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
2.2.2 | 201 | 7/14/2025 |
2.2.1 | 156 | 7/10/2025 |
2.2.0 | 135 | 7/10/2025 |
2.1.4 | 774 | 6/19/2025 |
2.1.3 | 359 | 5/23/2025 |
2.1.2 | 156 | 4/11/2025 |
2.0.1 | 160 | 4/10/2025 |
2.0.0 | 157 | 4/10/2025 |
1.3.4 | 205 | 4/10/2025 |
1.3.3 | 3,478 | 2/21/2023 |
1.3.2 | 291 | 2/21/2023 |
1.3.1 | 306 | 2/8/2023 |
1.3.0 | 297 | 2/7/2023 |
1.2.0 | 398 | 12/21/2021 |
1.1.0 | 392 | 11/11/2021 |
1.0.0 | 433 | 6/9/2021 |