From 68de8dd8c309a2f648d09cb1b9f81728855940a4 Mon Sep 17 00:00:00 2001 From: Tom Winter Date: Tue, 12 Mar 2024 16:48:01 +0100 Subject: [PATCH] fix: send webhook body correctly --- .../core/DefaultTriggerWebhookUseCase.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/notification/core/DefaultTriggerWebhookUseCase.kt b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/notification/core/DefaultTriggerWebhookUseCase.kt index 3f0317c..69e6204 100644 --- a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/notification/core/DefaultTriggerWebhookUseCase.kt +++ b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/notification/core/DefaultTriggerWebhookUseCase.kt @@ -1,12 +1,12 @@ package com.aamdigital.aambackendservice.notification.core -import com.aamdigital.aambackendservice.couchdb.core.getEmptyQueryParams import com.aamdigital.aambackendservice.domain.DomainReference import com.aamdigital.aambackendservice.notification.core.event.NotificationEvent import org.slf4j.LoggerFactory import org.springframework.http.HttpHeaders import org.springframework.http.HttpMethod import org.springframework.http.MediaType +import org.springframework.web.reactive.function.BodyInserters import org.springframework.web.reactive.function.client.WebClient import reactor.core.publisher.Mono import java.net.URI @@ -23,9 +23,6 @@ class DefaultTriggerWebhookUseCase( webhookRef = DomainReference(notificationEvent.webhookId) ) .flatMap { webhook -> - val queryParams = getEmptyQueryParams() - queryParams.set("calculation_id", notificationEvent.calculationId) - val uri = URI( uriParser.replacePlaceholder( webhook.target.url, @@ -41,12 +38,18 @@ class DefaultTriggerWebhookUseCase( it.scheme(uri.scheme) it.host(uri.host) it.path(uri.path) - it.queryParams(queryParams) it.build() } .headers { it.set(HttpHeaders.AUTHORIZATION, "Token ${webhook.authentication.secret}") } + .body( + BodyInserters.fromValue( + mapOf( + Pair("calculation_id", notificationEvent.calculationId) + ) + ) + ) .accept(MediaType.APPLICATION_JSON) .exchangeToMono { response -> response.bodyToMono(String::class.java)