diff --git a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/notification/core/DefaultTriggerWebhookUseCase.kt b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/notification/core/DefaultTriggerWebhookUseCase.kt index 0684f7c..a12b164 100644 --- a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/notification/core/DefaultTriggerWebhookUseCase.kt +++ b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/notification/core/DefaultTriggerWebhookUseCase.kt @@ -2,6 +2,7 @@ package com.aamdigital.aambackendservice.reporting.notification.core import com.aamdigital.aambackendservice.domain.DomainReference import com.aamdigital.aambackendservice.reporting.domain.event.NotificationEvent +import com.fasterxml.jackson.databind.ObjectMapper import org.slf4j.LoggerFactory import org.springframework.http.HttpHeaders import org.springframework.http.HttpMethod @@ -16,6 +17,7 @@ class DefaultTriggerWebhookUseCase( private val notificationStorage: NotificationStorage, private val httpClient: RestClient, private val uriParser: UriParser, + private val objectMapper: ObjectMapper, ) : TriggerWebhookUseCase { private val logger = LoggerFactory.getLogger(javaClass) @@ -44,9 +46,12 @@ class DefaultTriggerWebhookUseCase( .headers { it.set(HttpHeaders.AUTHORIZATION, "Token ${webhook.authentication.secret}") } + .contentType(MediaType.APPLICATION_JSON) .body( - mapOf( - Pair("calculation_id", notificationEvent.calculationId) + objectMapper.writeValueAsString( + hashMapOf( + "calculation_id" to notificationEvent.calculationId + ) ) ) .accept(MediaType.APPLICATION_JSON) diff --git a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/notification/di/NotificationConfiguration.kt b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/notification/di/NotificationConfiguration.kt index 064a955..76ef9b8 100644 --- a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/notification/di/NotificationConfiguration.kt +++ b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/notification/di/NotificationConfiguration.kt @@ -13,6 +13,7 @@ import com.aamdigital.aambackendservice.reporting.notification.storage.DefaultNo import com.aamdigital.aambackendservice.reporting.notification.storage.WebhookRepository import com.aamdigital.aambackendservice.reporting.reportcalculation.core.CreateReportCalculationUseCase import com.aamdigital.aambackendservice.reporting.reportcalculation.core.ReportCalculationStorage +import com.fasterxml.jackson.databind.ObjectMapper import org.springframework.beans.factory.annotation.Qualifier import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @@ -43,7 +44,8 @@ class NotificationConfiguration { notificationStorage: NotificationStorage, @Qualifier("webhook-web-client") restClient: RestClient, uriParser: UriParser, - ): TriggerWebhookUseCase = DefaultTriggerWebhookUseCase(notificationStorage, restClient, uriParser) + objectMapper: ObjectMapper + ): TriggerWebhookUseCase = DefaultTriggerWebhookUseCase(notificationStorage, restClient, uriParser, objectMapper) @Bean(name = ["webhook-web-client"]) fun webhookWebClient(): RestClient {