CXone Studio Snippet: Parsing JSON Response from GetRESTProxy in ASSIGN Block

Just noticed that my CXone Studio snippet is failing to extract nested JSON values from a REST API call. I am building a self-hosted automation pipeline where an n8n workflow triggers a CXone interaction, and I need to fetch user profile data via the CXone REST API within the Studio flow. The GET request succeeds, but the subsequent parsing logic in the ASSIGN block throws a null reference error.

Here are the steps to reproduce the issue:

  1. Define a GetRESTProxy action with the endpoint https://api.nice-incontact.com/ccapi/v2/users/{userId}.
  2. Set the HTTP method to GET and include the OAuth2 Bearer token in the headers.
  3. Execute the request. The debug log shows a 200 OK status with a valid JSON payload.
  4. Add an ASSIGN block to parse the response body into a local variable using json_decode().
  5. Attempt to access a nested property, such as user.profile.email, in a subsequent IF condition.

The code snippet for the ASSIGN block looks like this:

// Parse the raw response body
assign parsedResponse = json_decode(restResponse.body);

// Attempt to extract email
assign userEmail = parsedResponse.profile.email;

The error message in the Studio debug console is: NullReferenceException: Object reference not set to an instance of an object at line 4.

I have verified that the restResponse.body contains the expected JSON structure:

{
 "id": "12345",
 "profile": {
 "email": "[email protected]",
 "name": "John Doe"
 }
}

Despite this, parsedResponse appears to be null or malformed when passed to the next step. I suspect the issue might be related to how json_decode handles the string format returned by GetRESTProxy, or perhaps the variable scope is not persisting correctly between the REST action and the ASSIGN block. Has anyone encountered similar issues with nested object parsing in CXone Studio snippets? Is there a specific syntax I should use to safely access nested properties?