Webhook payload adding extra \ backslash character
search cancel

Webhook payload adding extra \ backslash character

book

Article ID: 413435

calendar_today

Updated On:

Products

CA Service Desk Manager CA Service Management - Service Desk Manager

Issue/Introduction

After adding a JSON code in the Payload Body of a Webhook Notification, SDM adds the "\" backslash character when sending the payload to the Webhook endpoint.

Example:

Payload Body code set in the Webhook Notification:


"name": "John", 
"age": 30
 }

 

Generated JSON code being sent by SDM that can be seen in NX_ROOT\log\jstd.log (In DEBUG level):


\"name\": \"John\", 
\"age\": 30
 }

Environment

Service Desk Manager 17.4 RU4 and previous releases.

Cause

The SDM code is not designed to send the code in JSON format; the payload is sent as a STRING only.

Resolution

The "\" backslash character is expected since the payload is sent as a string, and it's necessary to escape double quotes.

A possible workaround would need to add a converting service, written in php, python, NodeJS, or any language you are familiar with. SDM webhook would be configured to call that service, the service would read the content of the payload, and convert it into a JSON object.

Another option is to configure the endpoint (the application that receives the payload) to allow unscape.