CXone Studio Snippet: GetRESTProxy() throwing INVALID_FUNCTION on GET request

Working on a Studio script to fetch external CRM data during an inbound call flow. We’ve moved away from the older HTTP actions and are trying to use the Snippet code editor for more control over the request headers. I’m hitting a wall with the GetRESTProxy() function. Every time the script executes the snippet, it fails with an INVALID_FUNCTION error, but the syntax looks correct according to the docs.

Here’s the snippet code I’ve written:

// Initialize the proxy object
ASSIGN proxy = GetRESTProxy()

// Set the endpoint and method
ASSIGN proxy.Endpoint = "https://api.example.com/v1/customer/12345"
ASSIGN proxy.Method = "GET"

// Add necessary headers
ASSIGN proxy.Headers["Authorization"] = "Bearer " + $session.auth_token
ASSIGN proxy.Headers["Content-Type"] = "application/json"

// Execute the request
ASSIGN response = proxy.Execute()

// Check status
IF response.StatusCode == 200
 ASSIGN $session.cust_data = response.Body
ELSE
 ASSIGN $session.error_msg = "Failed to fetch data: " + response.StatusCode
END_IF

I’ve tried a few things to debug this:

  1. Verified the endpoint is reachable via Postman with the same token.
  2. Checked the Studio logs. The error occurs exactly at the ASSIGN proxy = GetRESTProxy() line, not during execution.
  3. Tried renaming the variable proxy to rest_client in case it was a reserved keyword, but same result.
  4. Confirmed the Studio version supports Snippet code (we’re on the latest platform update).

The weird part is that GetRESTProxy() works fine in other scripts in the same org. It’s only failing in this specific flow. Could there be a scope issue with how the snippet is initialized? Or is there a specific permission required for the Studio user running the flow that I’m missing?

Also, I noticed the docs mention GetRESTProxy returns an object, but I’m not sure if I need to instantiate it differently in Snippet vs. standard Studio actions. Any ideas on what’s causing the function to be marked as invalid here?