Why does this setting in the Set Variable node strip nested objects before the Data Action executes? The flow is designed to trigger a ServiceNow incident ticket via a webhook payload when a specific IVR path is taken. The payload structure requires a deeply nested JSON object for the u_custom_fields attribute. When testing locally, the payload appears correct, but the Genesys Cloud logs show a 400 Bad Request response from the ServiceNow endpoint. The error message indicates Invalid JSON: Unexpected token.
The issue seems to be that the Set Variable node is flattening the structure or escaping quotes incorrectly during the transformation step. The environment is Genesys Cloud v2023.11 with ServiceNow v14.1. The REST API endpoint is configured with basic authentication and a Content-Type: application/json header. The payload uses standard JSON syntax, yet the platform seems to misinterpret the curly braces within the transformation step. Has anyone successfully passed a complex nested object from an Architect flow to a third-party REST API without resorting to a base64 encoding workaround?
The best way to fix this is to avoid passing the entire nested object directly into the Set Variable node’s value field. The node often flattens complex structures or fails to serialize deep JSON properly when bound directly to a flow variable. Instead, construct the nested object as a raw string within the Set Variable node, then parse it later.
For the ServiceNow u_custom_fields attribute, try this approach in the Set Variable node:
- Create a new variable, e.g.,
snow_payload_str.
- In the value field, use a static JSON string with dynamic references for the inner values, but keep the structure as text. For example:
{"category": "{{flow.cat}}", "subcategory": "{{flow.subcat}}"}
- In the subsequent Data Action or Webhook node, do not pass
snow_payload_str directly as a JSON object. Instead, pass it as a string and ensure the ServiceNow endpoint expects a JSON string, or use a JSON Parse node if your platform version supports it before the action.
A more robust pattern for bulk export and legal discovery workflows-which I often apply to ensure chain of custody integrity-is to build the JSON payload in a preceding Script node (JavaScript) and assign the resulting string to a flow variable. This bypasses the UI serialization limits entirely.
Example JavaScript snippet for the Script node:
Then pass flow.snow_payload.value to the webhook. This method preserves the exact nesting required by ServiceNow and prevents the 400 Bad Request caused by malformed JSON. Also, verify that the Content-Type header in the Webhook action is explicitly set to application/json.
var customFields = {
"category": flow.cat.value,
"subcategory": flow.subcat.value
};
flow.snow_payload.set(JSON.stringify(customFields));