We’ve got a CXone Studio flow where a SNIPPET action needs to call our internal order system and extract the customer tier. The REST call is returning a 200 OK, but the subsequent ASSIGN action keeps failing because the JSON path isn’t resolving correctly.
Here’s the relevant snippet code:
rest = GetRESTProxy()
rest.setMethod("GET")
rest.setURL("https://api.internal-orders.com/v1/status?ref={{case.ref_num}}")
response = rest.doRequest()
if rest.getResponseCode() == 200 {
// Attempting to parse the JSON body
data = JSON.parse(response.getBody())
customerTier = data.tier
}
The issue is that data seems to be undefined or null when the script reaches the assignment line. I’ve logged response.getBody() and it looks like valid JSON: {"status": "found", "tier": "gold"}.
We’ve tried wrapping it in a try-catch block, but the error handler doesn’t trigger, which suggests the parse function might not be throwing, or the object structure is different than expected. Is there a specific method required to access the response body in a Studio SNIPPET context? The standard JSON.parse doesn’t seem to be available in the sandboxed environment, or maybe I’m calling it wrong. Any pointers on the correct syntax for extracting nested values from a REST response in Studio?