INVALID_FUNCTION error on GetRESTProxy in Studio Snippet action

Running into a wall with a Snippet action in Studio. The goal is simple: hit an internal endpoint to check inventory, then branch based on the status code. The REST Proxy is set up and working fine in the trace. I can see the 200 OK and the JSON payload coming back.

Problem is the Snippet logic. Every time the script hits the ASSIGN statement, it throws an INVALID_FUNCTION error.

Here is the snippet code:

ASSIGN inventoryCheck = GetRESTProxy("InventoryLookup", "GET", "/api/v1/stock", {}, "")
IF (inventoryCheck.statusCode == 200) THEN
 ASSIGN isAvailable = true
ELSE
 ASSIGN isAvailable = false
END IF

The error points directly to the GetRESTProxy line. I’ve checked the Studio documentation. The signature looks right. GetRESTProxy(proxyName, method, url, headers, body).

Wait. The body parameter. I’m passing an empty string "". Maybe that’s the issue? Tried passing {} instead. Same error.

Tried wrapping the call in a try-catch block within the snippet. Studio doesn’t support standard JS try-catch in Snippets. It’s pseudo-code.

Checked the proxy name. It’s definitely “InventoryLookup”. Case sensitive. Checked the method. GET. Checked the URL. Matches the proxy definition.

Is GetRESTProxy supposed to return an object with a statusCode property immediately? Or does it return a future/promise that needs to be resolved first? The docs are vague on the return type. They just say “returns the response”.

If it’s async, how do I handle it in a synchronous Snippet block? Studio Snippets don’t have an await keyword.

Also noticed that if I remove the GetRESTProxy call and just assign a static value, the IF statement works. So the branching logic is fine. It’s purely the function call failing.

Error log from the interaction trace:
Snippet Error: INVALID_FUNCTION - Function 'GetRESTProxy' not found or invalid arguments at line 1

Tried renaming the function. Tried using GetRestProxy (lowercase r). No luck.

Anyone else hit this? Is there a specific version of Studio required for this function? We’re on the latest release.

Feeling like I’m missing something obvious about the parameter types. Maybe the headers object needs to be null instead of empty?

Here is the proxy config for reference:

The endpoint works in Postman. Works in the Studio REST Proxy test tab. Just breaks in the Snippet.

Need to move on to the next step in the flow. Can’t wait for support to reply.

Any hints on the correct syntax? Or is this a known bug?

Thanks.

You’re mixing up the context. The GetRESTProxy function is not available in the Snippet action context the way you’re calling it. The documentation for the Snippet action explicitly states that it supports standard JavaScript functions and specific Genesys Cloud helper functions, but GetRESTProxy is a construct used in the Proxy configuration itself, not a callable function within the Snippet’s JavaScript execution environment.

From the docs: “Snippet actions allow you to run custom JavaScript code. The code has access to the session variables and standard JavaScript libraries.”

What you actually need to do is access the response from the preceding Proxy step directly via the session variables. If your Proxy step is named CheckInventory, the response is already stored in the session. You don’t need to “get” it again.

Here is how the assignment should look in the Snippet:

// Assuming the Proxy step is named "CheckInventory"
// The response is available in session variables automatically
var statusCode = session.getVariable("CheckInventory.statusCode");
var responseBody = session.getVariable("CheckInventory.response.body");

// Parse the JSON if needed
var inventoryData = JSON.parse(responseBody);

// Set your branch condition variable
session.setVariable("hasStock", inventoryData.stock > 0);

The INVALID_FUNCTION error happens because the JS engine in the Snippet doesn’t recognize GetRESTProxy as a valid function. It’s looking for a method that doesn’t exist in that scope.

Also, double-check your Proxy step configuration. Ensure “Store Response in Session” is checked. If that’s off, the variables won’t be there, and you’ll get undefined instead of an error, which is worse for debugging.

If you need to manipulate the payload before branching, do it in the Snippet using session.getVariable and session.setVariable. Don’t try to re-fetch or re-proxy inside the Snippet. It’s not designed for that. Keep the Snippet logic simple: read variables, transform data, set new variables.

The timezone difference might be affecting your token if you’re using OAuth in the Proxy, but that’s a separate issue. For now, fix the variable access pattern.