What is the reason this setting causes a server error when parsing the response?
I am trying to call an external API from a Studio flow and capture the result. I followed the documentation exactly. The docs state “The GetRESTProxy action returns a handle that can be used to make HTTP requests.” I copy-pasted the snippet structure but I get an error. Here is my code:
ASSIGN restHandle = GetRESTProxy();
ASSIGN response = restHandle.ExecuteRequest('POST', 'https://api.example.com/data', '{"key": "value"}', '', '');
ASSIGN jsonResult = JsonParse(response.Body);
ASSIGN myVar = jsonResult.id;
The flow fails at the JsonParse line. The error log says “Invalid JSON format.” But the response body looks correct. I printed the response.Body and it shows: {“id”: 123, “status”: “ok”}. This is valid JSON. I do not understand why it fails. The documentation for JsonParse says “The input must be a valid JSON string.” It is a valid string. I am using the latest Studio version. Is there a hidden character issue? The docs do not mention trimming whitespace. I tried adding Trim(response.Body) but it still fails. The error is still “Invalid JSON format.” This is frustrating. I have checked the API endpoint and it returns 200 OK. The issue is in Studio. I need to know what syntax is correct. I follow the docs strictly. If the docs are wrong, please tell me. I cannot proceed with my flow. This blocks my entire project. I need a working example of parsing a simple JSON response in a SNIPPET. Please provide the exact code. Do not give general advice. I need the specific syntax that works. I have tried many variations. None work. The error persists. I am stuck. Please help.
What’s probably happening here is that a mismatch between the expected JSON structure and what the external API actually returns, combined with how NICE CXone Studio handles the GetRESTProxy response object. The 500 error indicates a server-side parsing failure within the flow engine, not necessarily your code logic.
Studio expects the ExecuteRequest output to be a specific object containing statusCode, responseHeaders, and responseBody. If the target API returns a malformed JSON or a raw string, the internal parser crashes.
Verify the actual payload using a separate test. In Azure Functions, I often see this when the Content-Type header is missing or incorrect. Ensure your external API returns application/json.
Here is a safer pattern to inspect the raw response before parsing:
// Inside a Studio Script node or similar debug step
var rawResponse = restHandle.GetResponseBody();
// Log rawResponse to see if it is valid JSON
// If it is valid, parse it explicitly
var parsedData = JSON.parse(rawResponse);
Check if your external endpoint requires authentication headers that are missing. Also, ensure the ExecuteRequest call includes the correct Accept: application/json header in the request options.
Have you tried validating the raw response body before attempting to parse it within the Studio flow, as the 500 error often stems from malformed JSON returned by the external service rather than the proxy configuration itself. I see this frequently when integrating Genesys Cloud analytics endpoints into NICE CXone flows. The GetRESTProxy handle returns a string that must be explicitly converted if you are using it in a downstream logic step that expects an object. You can isolate the issue by logging the raw string first.
ASSIGN rawResponse = restHandle.ExecuteRequest('POST', 'https://api.example.com/data', payload);
ASSIGN debugLog = rawResponse.responseBody;
// Check if debugLog is valid JSON before parsing
ASSIGN parsedData = JSON.parse(rawResponse.responseBody);
This approach prevents the flow engine from crashing on invalid syntax and allows you to inspect the exact payload causing the failure.