4D-NetKit

GraphNotificationHandler Class

Overview

GraphNotificationHandler is a shared singleton HTTP handler for incoming Microsoft Graph change notifications. It is registered at the /4dnk-graph-notification route and handles both validation requests and notification payloads, routing them to the appropriate active GraphNotification monitors.

To use push mode with the host web server, add the following entry to Project/Sources/HTTPHandlers.json:

[
  {
    "class": "NetKit.GraphNotificationHandler",
    "method": "getResponse",
    "regexPattern": "/4dnk-graph-notification",
    "verbs": "post"
  }
]

Notes:

Table of Contents

Functions

Functions

.getResponse()

.getResponse( request : 4D.IncomingMessage ) : 4D.OutgoingMessage

Parameters

Parameter Type   Description
request 4D.IncomingMessage -> Incoming HTTP request from Microsoft Graph.
Result 4D.OutgoingMessage <- HTTP 200 + validationToken for validation requests; HTTP 202 for notification payloads; HTTP 400 when request is Null.

Description

.getResponse() handles two types of incoming requests from Microsoft Graph:

  1. ValidationPOST ?validationToken=<token>: Microsoft sends this to verify the endpoint. The response must echo the token as plain text with status 200.
  2. NotificationPOST with JSON body containing {value: [...]} array: routes each item to the matching GraphNotification monitor via Storage.graphNotifications.

See also