Building a Data Action to call our internal CRM endpoint for lead qualification. The goal is to fetch the lead score and map specific fields to Architect variables for downstream routing.
The Data Action configuration looks standard. I’m using the GetRESTProxy to handle the HTTP call. Here is the relevant code:
var rest = GetRESTProxy();
var response = rest.sendRequest({
"method": "GET",
"url": "https://api.crm.internal/v1/leads/" + System.InteractionId,
"headers": {
"Authorization": "Bearer " + System.AccessToken,
"Content-Type": "application/json"
}
});
if (response.statusCode == 200) {
ASSIGN("LeadScore", response.jsonBody.score);
ASSIGN("Segment", response.jsonBody.segment);
ASSIGN("IsValid", true);
} else {
ASSIGN("IsValid", false);
ASSIGN("ErrorMessage", response.statusCode);
}
The issue isn’t the HTTP call. The logs show a 200 OK status. The IsValid flag gets set to true. But LeadScore and Segment come back null or empty in the next step.
I added a debug print to dump response.jsonBody into a temporary variable. The output looks correct:
{
"score": 85,
"segment": "high_value",
"last_contact": "2023-10-25"
}
So the JSON structure is flat. No nested objects causing path issues. I’ve tried changing the ASSIGN syntax to response.jsonBody["score"] just in case, but no luck. The variables remain blank.
Is there a known issue with how parses JSON numbers into integer variables? Or maybe a timing issue with the REST Proxy response object? I’ve restarted the script engine a few times to clear any cache, but the behavior is consistent.
Any ideas on why the mapping fails even though the payload is clearly present in the debug output?