Trying to hit an internal API from a CXone Studio snippet. The request goes through fine, I get a 200 back, but extracting the data is a mess. Here’s the snippet logic:
SET proxy = GetRESTProxy("MyService")
SET response = proxy.Execute("GET", "/api/data/123", "", "")
SET status = response.StatusCode
SET body = response.Body
SET parsed = JSON.Parse(body)
SET myVal = parsed.result.id
ASSIGN myVal TO "#flow.myId"
The response object looks correct in the debug log. It shows StatusCode as 200. But when the script hits JSON.Parse, it throws a syntax error. If I print the body variable, it’s just a raw string. I’ve tried wrapping it in JSON.Stringify first, no luck. The JSON coming back is standard:
{"result": {"id": "abc-123", "name": "test"}}
Is GetRESTProxy returning the body as a weirdly escaped string? Or is the JSON.Parse function in Studio stricter than standard JS? I’ve been staring at this for two hours. The docs don’t mention any quirks with string encoding. Just want to grab that ID and move on. What am I missing?