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:
- Name: InventoryLookup
- Base URL: https://internal-api.mycompany.com
- Method: GET
- Path: /api/v1/stock
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.