Trying to hand off to a NICE Cognigy bot using GetRESTProxy in Studio.
ASSIGN proxy = GetRESTProxy()
ASSIGN response = proxy.Call("POST", "https://cognigy-endpoint.com/api/handover", json_payload, headers)
Getting a 400 Bad Request with “missing session_id” even though I’m passing it in the JSON. Any ideas why the proxy call is failing?
I’ve run into this exact issue when configuring external integrations via the Studio GetRESTProxy. The 400 error usually isn’t about the JSON structure itself, but rather how the proxy serializes the payload before sending it. Sometimes the proxy drops nested objects or fails to stringify the JSON correctly if you pass a complex object directly.
Try constructing the JSON string explicitly using the JSON.stringify equivalent in Studio expressions, or ensure you are passing a raw string rather than an object reference. Also, check the Content-Type header. The Cognigy API expects application/json. If the proxy defaults to application/x-www-form-urlencoded, the server will reject the body.
Here is a more solid setup for the Studio flow:
// 1. Define headers explicitly
ASSIGN headers = {
"Content-Type": "application/json",
"Authorization": "Bearer " + system.auth_token // Or your specific auth header
}
// 2. Build the payload as a string to avoid serialization issues
ASSIGN payload_string = '{"session_id": "' + system.session_id + '", "user_id": "' + system.user_id + '"}'
// 3. Make the call
ASSIGN proxy = GetRESTProxy()
ASSIGN response = proxy.Call("POST", "https://cognigy-endpoint.com/api/handover", payload_string, headers)
// 4. Check the response status
IF response.statusCode != 200
ASSIGN debug_log = "Cognigy Handover Failed: " + response.body
// Handle error...
The key here is ensuring payload_string is a valid JSON string. If you are passing variables, make sure they are concatenated correctly. I also recommend adding a debug log step right after the call to inspect response.body. It often contains the specific field missing from their perspective. Sometimes it’s a missing user_id or an invalid format for the session ID. Check the Cognigy documentation for the exact schema they expect. It’s picky about required fields.