Table of Contents

Namespace Line.OpenApi.Messaging.Webhook

Classes

WebhookException

Base type for exceptions raised during webhook receive processing (signature validation / deserialization). Callers can branch on the individual derived types, or catch them all through this base.

WebhookPayloadException

The signature was valid, but the body JSON could not be deserialized into Line.OpenApi.Messaging.Webhook.Generated.Models.CallbackRequest.

WebhookRequestParser

Entry point for receiving LINE webhooks. A thin helper that bundles x-line-signature signature validation (WebhookSignatureValidator) and deserialization of the body into Line.OpenApi.Messaging.Webhook.Generated.Models.CallbackRequest into a single call.

Deserialization is done by instantiating Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory directly and does not depend at all on Kiota's global default serializer registry (ParseNodeFactoryRegistry.DefaultInstance / ApiClientBuilder.RegisterDefaultDeserializer). (KiotaJsonSerializer internally consults that default registry, so it fails in a clean process where no JSON factory has been registered. Using the factory directly does not carry that assumption.) As a result it works standalone even in an app that has not constructed the Messaging client, and has no side effects (the regression is guarded by the standalone assembly Line.OpenApi.Messaging.Webhook.IsolationTests).

Polymorphic reconstruction of the event array (dispatch to Line.OpenApi.Messaging.Webhook.Generated.Models.MessageEvent etc. by the type discriminator, with a fallback to the base Line.OpenApi.Messaging.Webhook.Generated.Models.Event for unknown types) is handled by the generated code. This helper only returns the Line.OpenApi.Messaging.Webhook.Generated.Models.CallbackRequest; the subsequent event branching is done on the caller side (see README).

Example usage with ASP.NET Core (obtaining the raw body and signature header is the caller's responsibility):

var body = await ReadRawBodyBytesAsync(Request);          // raw bytes (same as what is signed)
var sig  = Request.Headers["x-line-signature"];
CallbackRequest callback = await parser.ParseAsync(body, sig);  // throws on invalid signature
WebhookSignatureException

The HMAC-SHA256 signature validation of x-line-signature failed (tampering, key mismatch, missing header, etc.). The request should be rejected. In ASP.NET, mapping this to 401/400 is a good choice.