ConnectorTriggerPayload.ReadAsync<TPayload> Method

Definition

Reads a metadata trigger callback (for example OneDrive OnNewFilesV2) from a stream into its typed payload. The expected wire shape is {"body":{"value":[{...item...}]}}.

public static System.Threading.Tasks.ValueTask<TPayload?> ReadAsync<TPayload>(System.IO.Stream body, long maxBodySizeBytes = 104857600, System.Threading.CancellationToken cancellationToken = default) where TPayload : class;
static member ReadAsync : System.IO.Stream * int64 * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'Payload (requires 'Payload : null)> (requires 'Payload : null)
Public Shared Function ReadAsync(Of TPayload As Class) (body As Stream, Optional maxBodySizeBytes As Long = 104857600, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of TPayload)

Type Parameters

TPayload

The connector-specific payload type, a subclass of TriggerCallbackPayload<T> (for example OneDriveForBusinessOnNewFilesTriggerPayload).

Parameters

body
Stream

The callback body stream (for example HttpRequestData.Body). The stream is read but not disposed; the caller retains ownership.

maxBodySizeBytes
Int64

The maximum number of bytes to read from body before failing. Defaults to DefaultMaxBodySizeBytes.

cancellationToken
CancellationToken

The cancellation token.

Returns

ValueTask<TPayload>

The deserialized payload, or null when the body is JSON null.

Exceptions

body is null.

maxBodySizeBytes is not greater than zero.

body exceeded maxBodySizeBytes.

The body was a base64 string (a binary-content trigger such as OnNewFileV2) rather than a metadata object; read it with ReadBinaryContentAsync(Stream, Int64, CancellationToken) instead.

Applies to