Table of Contents

Method GetOrCreateIotItemAsync

Namespace
Kepware.Api.ClientHandler
Assembly
Kepware.Api.dll

GetOrCreateIotItemAsync(string, IotAgent, IDictionary<string, object>?, CancellationToken)

Gets or creates an IoT Item for the specified server tag under the given parent agent. If the item exists, it is loaded and returned. If it does not exist, it is created with the specified properties. The IoT Item name is derived from the server tag by replacing dots with underscores and stripping any leading underscore.

public Task<IotItem> GetOrCreateIotItemAsync(string serverTag, IotAgent parentAgent, IDictionary<string, object>? properties = null, CancellationToken cancellationToken = default)

Parameters

serverTag string

The dot-delimited server tag reference (e.g., "Channel1.Device1.Tag1").

parentAgent IotAgent

The parent agent that will own the IoT Item.

properties IDictionary<string, object>

Optional properties to set on the IoT Item.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IotItem>

A task that represents the asynchronous operation. The task result contains the created or loaded IotItem.

Exceptions

ArgumentException

Thrown when the server tag is null or empty.

ArgumentNullException

Thrown when the parent agent is null.

InvalidOperationException

Thrown when the item cannot be created or loaded.