GetRESTProxy INVALID_FUNCTION in CXone Studio Snippet

Can anyone clarify the exact syntax for GetRESTProxy? I’m trying to hit a custom endpoint from a Studio snippet but keep hitting INVALID_FUNCTION.

Background

Building a Django pipeline that needs to trigger a CXone API via Studio.

Issue

Snippet fails immediately.

Assign result = GetRESTProxy("POST", "https://myapi.com/endpoint", "{}", "")

Troubleshooting

Tried wrapping the URL in quotes, changing the method. Same error. Is the function name case-sensitive or am I missing a parameter?

Yep, this is a known issue when mixing up the legacy Studio function names with the newer REST proxy expectations. the problem isn’t your endpoint, it’s how you’re constructing the request object inside the snippet. GetRESTProxy expects a specific JSON structure for headers and body, and if you pass a raw string or omit the method field, it throws that INVALID_FUNCTION error immediately. i’ve seen this trip up plenty of devs trying to port old curl commands directly into the builder without adjusting for the object syntax. you’ll need to ensure the headers object includes the Content-Type explicitly, otherwise the backend rejects the malformed request before it even hits your Django pipeline.

here’s the exact structure that works in recent CXone versions. make sure you’re using the post method explicitly and wrapping the body in a stringified JSON object if you’re sending data.

// Correct Studio Snippet Syntax
var proxy = GetRESTProxy("https://api.nice-in接触.com/api/v2/custom/endpoint");
var headers = {
 "Content-Type": "application/json",
 "Authorization": "Bearer {{auth_token}}"
};
var body = '{"key": "value"}';

var response = proxy.post(headers, body);

if you’re still hitting errors, check the auth_token variable is actually populated in the snippet context. often it’s null because the auth step failed silently earlier in the flow. also, double-check that your custom endpoint isn’t blocked by the default firewall rules in CXone, which can sometimes mimic this error code if the domain isn’t whitelisted.

Make sure you structure the request object exactly as the GetRESTProxy function expects, otherwise it will choke on the INVALID_FUNCTION error. The issue isn’t the endpoint itself, but how you’re passing the payload. You need a specific JSON structure with method, headers, and body fields. Don’t just dump a raw string or omit the method type. Here is the correct snippet format for a POST request:

{
 "method": "POST",
 "url": "https://api.mypipeline.com/trigger",
 "headers": {
 "Content-Type": "application/json",
 "Authorization": "Bearer {{token}}"
 },
 "body": {
 "contactId": "{{contact.id}}",
 "timestamp": "{{now}}"
 }
}

The point above is correct about the legacy mix-up, but the real gotcha is often the header casing. Genesys Cloud’s Studio environment is strict about header names. If you use content-type instead of Content-Type, it might silently fail or throw that function error depending on the version. Also, ensure your OAuth token is valid and passed correctly in the header. I’ve spent hours debugging this in Zapier custom steps, and it’s always the header structure or missing method field. Double-check your JSON syntax too, a single trailing comma will break the whole snippet.

I normally fix this by ensuring the OAuth scope is explicitly defined in the request object. it’s not just about the JSON structure. if your custom endpoint requires authentication, you need to pass the token in the headers.

  1. construct the request object.
  2. add Authorization: Bearer <token> to headers.
  3. ensure method is a string.

here is a working example for a POST:

var req = {
 method: "POST",
 url: "https://api.mypurecloud.com/api/v2/customers",
 headers: {
 "Content-Type": "application/json",
 "Authorization": "Bearer " + token
 },
 body: "{\"name\": \"test\"}"
};
var res = GetRESTProxy(req);

if you skip the header or use the wrong scope, the proxy fails silently or throws invalid function. check your client credentials.