From 89a26e7284708dda9f7fb829341503fef33ddc85 Mon Sep 17 00:00:00 2001 From: Soeren Leibach Date: Tue, 10 Mar 2026 16:15:42 +0100 Subject: [PATCH] add notification POST response logging --- CHANGELOG.md | 9 +++++++++ srv/notifyToRest.js | 11 +++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b52208a..d5d32b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). The format is based on [Keep a Changelog](http://keepachangelog.com/). +## [Unreleased] + +### Added + +- Log full response body and headers when the `notifications` logger is enabled at debug level. +- Return the full HTTP response from the REST notification handler. + Note: With outbox enabled (default), the application's `await notify()` resolves when + the message is queued; the return value is only available when `outbox: false`. + ## Version 0.3.0 ### Added diff --git a/srv/notifyToRest.js b/srv/notifyToRest.js index aa33316..1491a0a 100644 --- a/srv/notifyToRest.js +++ b/srv/notifyToRest.js @@ -24,12 +24,19 @@ module.exports = exports = class NotifyToRest extends NotificationService { LOG._info && LOG.info( `Sending notification of key: ${notificationData.NotificationTypeKey} and version: ${notificationData.NotificationTypeVersion}` ); - await executeHttpRequest(notificationDestination, { + const response = await executeHttpRequest(notificationDestination, { url: `${NOTIFICATIONS_API_ENDPOINT}/Notifications`, method: "post", data: notificationData, - headers: csrfHeaders, + headers: { ...csrfHeaders, Accept: "application/json" }, }); + if (LOG._debug) { + LOG.debug("Notification sent", { + body: response?.data, + headers: response?.headers, + }); + } + return response; } catch (err) { const message = err.response.data?.error?.message?.value ?? err.response.message; const error = new cds.error(message);