Hitting a wall with a Studio Snippet that needs to call an external REST API. The goal is simple: grab a token, then fetch user data. The first call works fine, but the second one fails immediately with INVALID_FUNCTION.
Here’s the snippet logic:
ASSIGN tokenResponse = GetRESTProxy("https://auth.example.com/token", "POST", {"grant_type": "client_credentials"}, {}, {})
ASSIGN token = tokenResponse.body.access_token
ASSIGN headers = {"Authorization": "Bearer " + token}
ASSIGN userData = GetRESTProxy("https://api.example.com/user/123", "GET", {}, headers, {})
The error log points specifically to the second GetRESTProxy call. The headers object looks valid, and I’ve double-checked the token value in the debug trace-it’s not null or empty.
I suspect the issue is how the headers parameter is being passed. The docs for GetRESTProxy are sparse on the exact JSON structure expected for the headers argument in Studio Snippets. Is it expecting a JSON string or an object literal?
If I pass it as a stringified JSON, I get a different error (INVALID_ARGUMENT). If I pass it as an object, I get INVALID_FUNCTION.
Also, noticed that the first call works with empty headers {}. Maybe the SDK or Studio runtime is choking on the dynamic header construction.
Anyone else hit this? Is there a specific syntax for passing headers in GetRESTProxy that isn’t documented? Or is this a known bug in the Studio engine?
Tried restarting the snippet, no change. Tried hardcoding the header values, still fails.
Need a workaround or the correct syntax. The current approach is blocking deployment.