Hi
I have made this script to pull data from the TFE Rest Configurator, and i hope that there is somebody that could see the problem.
The Problem is that from the script, it will not replace the jsCustomerPhoneNumber_cv in TFE Rest Configurator ID 88 to the URL, but keep the exsiting pre code number.
From within TFE Rest Configurator it is setup and has this (Get) URL https://url/admin/lookup?search=+4812345678 and if i execute it wil return this:
{
"status": "success",
"data": [
{
"operatorId": "123456",
"username": "name@host.com",
"name": "API Testing",
"email": "name@host.com",
"phoneNumber": "+4812345678",
"role": "Subscription Administrator"
}
]
}
Callflow
/* ----- 1. Clear call variables ----- */
JSON CLEAR STRING jsStatus_cv
JSON CLEAR OBJECT joRequest_cv
JSON CLEAR OBJECT joParameters_cv
JSON CLEAR ARRAY jaData_cv
JSON CLEAR STRING jsOperatorId_cv
JSON CLEAR STRING jsUsername_cv
JSON CLEAR STRING jsName_cv
JSON CLEAR STRING jsEmail_cv
JSON CLEAR STRING jsPhone_cv
JSON CLEAR STRING jsRole_cv
JSON CLEAR OBJECT joResponse_cv
/* Extract AD_CLID from Contact Data */
ASSIGN CLID TO cv_CLID
CONVERT cv_CLID TO STRING sCustomerPhoneNumber_cv
APPEND "%2B45" TO sCustomerPhoneNumber_cv
/* Convert AD_CLID to a JSON string */
CONVERT sCustomerPhoneNumber_cv TO JSON STRING jsCustomerPhoneNumber_cv
/* (Optional) Log the AD_CLID value for debugging */
LOG jsCustomerPhoneNumber_cv /*"jsCustomerPhoneNumber_cv \"quotation\""*/
/* ——— 2. Build the REST request object ——— */
/* Tell TFE which REST definition to use (ID=5) and that we’re passing Query String params */
JSON ADD KEYVALUE "JSON:ID" : "JSON:88" TO OBJECT joRequest_cv
JSON ADD KEYVALUE "JSON
arameterType" : "JSON:Query String" TO OBJECT joRequest_cv
/* Now add the actual parameters */
JSON ADD KEYVALUE "JSON:search" : "JSON:jsCustomerPhoneNumber_cv" TO OBJECT joParameters_cv
/* Nest parameters under the “parameters” label */
JSON ADD KEYVALUE OBJECT joParameters_cv WITH LABEL "JSON
arameters" TO OBJECT joRequest_cv
/* ——— 3. Execute the API call ——— */
EXECUTE REST REQUEST joRequest_cv TIMEOUT 10 RESPONSE joResponse_cv
/* 4) Check status */
JSON EXTRACT LABEL "JSON:status" FROM OBJECT joResponse_cv TO STRING jsStatus_cv
IF jsStatus_cv = "JSON:failure" THEN
LOG "Lookup API call failed"
/* error fallback here */
END IF
/* 5) On success, extract the wrapped array and then each field */
IF jsStatus_cv = "JSON:success" THEN
/* 5a) Pull the array from 'data' */
JSON EXTRACT LABEL "JSON:data" FROM OBJECT joResponse_cv TO ARRAY jaData_cv
/* 5b) JSON engine will extract from the *first* element of jaData_cv */
JSON EXTRACT LABEL "JSON
peratorId" FROM ARRAY jaData_cv TO STRING jsOperatorId_cv
JSON EXTRACT LABEL "JSON:username" FROM ARRAY jaData_cv TO STRING jsUsername_cv
JSON EXTRACT LABEL "JSON:name" FROM ARRAY jaData_cv TO STRING jsName_cv
JSON EXTRACT LABEL "JSON:email" FROM ARRAY jaData_cv TO STRING jsEmail_cv
JSON EXTRACT LABEL "JSON
honeNumber" FROM ARRAY jaData_cv TO STRING jsPhone_cv
JSON EXTRACT LABEL "JSON:role" FROM ARRAY jaData_cv TO STRING jsRole_cv
/* 5c) Route based on role */
IF jsRole_cv = "JSON:Subscription Administrator" THEN
LOG "Routing to Subscription Administrator skillset"
/* QUEUE or ROUTE command here */
ELSE
LOG "Routing to default skillset"
END IF
END IF
I have made this script to pull data from the TFE Rest Configurator, and i hope that there is somebody that could see the problem.
The Problem is that from the script, it will not replace the jsCustomerPhoneNumber_cv in TFE Rest Configurator ID 88 to the URL, but keep the exsiting pre code number.
From within TFE Rest Configurator it is setup and has this (Get) URL https://url/admin/lookup?search=+4812345678 and if i execute it wil return this:
{
"status": "success",
"data": [
{
"operatorId": "123456",
"username": "name@host.com",
"name": "API Testing",
"email": "name@host.com",
"phoneNumber": "+4812345678",
"role": "Subscription Administrator"
}
]
}
Callflow
/* ----- 1. Clear call variables ----- */
JSON CLEAR STRING jsStatus_cv
JSON CLEAR OBJECT joRequest_cv
JSON CLEAR OBJECT joParameters_cv
JSON CLEAR ARRAY jaData_cv
JSON CLEAR STRING jsOperatorId_cv
JSON CLEAR STRING jsUsername_cv
JSON CLEAR STRING jsName_cv
JSON CLEAR STRING jsEmail_cv
JSON CLEAR STRING jsPhone_cv
JSON CLEAR STRING jsRole_cv
JSON CLEAR OBJECT joResponse_cv
/* Extract AD_CLID from Contact Data */
ASSIGN CLID TO cv_CLID
CONVERT cv_CLID TO STRING sCustomerPhoneNumber_cv
APPEND "%2B45" TO sCustomerPhoneNumber_cv
/* Convert AD_CLID to a JSON string */
CONVERT sCustomerPhoneNumber_cv TO JSON STRING jsCustomerPhoneNumber_cv
/* (Optional) Log the AD_CLID value for debugging */
LOG jsCustomerPhoneNumber_cv /*"jsCustomerPhoneNumber_cv \"quotation\""*/
/* ——— 2. Build the REST request object ——— */
/* Tell TFE which REST definition to use (ID=5) and that we’re passing Query String params */
JSON ADD KEYVALUE "JSON:ID" : "JSON:88" TO OBJECT joRequest_cv
JSON ADD KEYVALUE "JSON
/* Now add the actual parameters */
JSON ADD KEYVALUE "JSON:search" : "JSON:jsCustomerPhoneNumber_cv" TO OBJECT joParameters_cv
/* Nest parameters under the “parameters” label */
JSON ADD KEYVALUE OBJECT joParameters_cv WITH LABEL "JSON
/* ——— 3. Execute the API call ——— */
EXECUTE REST REQUEST joRequest_cv TIMEOUT 10 RESPONSE joResponse_cv
/* 4) Check status */
JSON EXTRACT LABEL "JSON:status" FROM OBJECT joResponse_cv TO STRING jsStatus_cv
IF jsStatus_cv = "JSON:failure" THEN
LOG "Lookup API call failed"
/* error fallback here */
END IF
/* 5) On success, extract the wrapped array and then each field */
IF jsStatus_cv = "JSON:success" THEN
/* 5a) Pull the array from 'data' */
JSON EXTRACT LABEL "JSON:data" FROM OBJECT joResponse_cv TO ARRAY jaData_cv
/* 5b) JSON engine will extract from the *first* element of jaData_cv */
JSON EXTRACT LABEL "JSON
JSON EXTRACT LABEL "JSON:username" FROM ARRAY jaData_cv TO STRING jsUsername_cv
JSON EXTRACT LABEL "JSON:name" FROM ARRAY jaData_cv TO STRING jsName_cv
JSON EXTRACT LABEL "JSON:email" FROM ARRAY jaData_cv TO STRING jsEmail_cv
JSON EXTRACT LABEL "JSON
JSON EXTRACT LABEL "JSON:role" FROM ARRAY jaData_cv TO STRING jsRole_cv
/* 5c) Route based on role */
IF jsRole_cv = "JSON:Subscription Administrator" THEN
LOG "Routing to Subscription Administrator skillset"
/* QUEUE or ROUTE command here */
ELSE
LOG "Routing to default skillset"
END IF
END IF