Thank you Gregory for your response, i figured the same and able to get the desired results.
For Example:
{
"message": "Internal Server Error",
"code": "internal.server.error",
"status": 500,
"messageParams": {},
"contextId": "21178bd3-a207-43d1-a635-daa3c3cbfc35",
"details": [
{
"errorCode": "ACTION.REMOTE_ENDPOINT"
}
],
"errors": [
{
"message": "REST call for action execute failed. Message: Invoked function failed. Response from function: Function execution failed with error Type: Unhandled; Message: errorType:BusinessError,errorMessage:status:400,success:false,code:BAD_REQUEST,message:Simulated failure via fail flag.,receivedParams:name:test,fail:true,trace:[BusinessError: status:400,success:false,code:BAD_REQUEST,message:Simulated failure via fail flag.,receivedParams:name:test,fail:true, at core (/var/task/index.js:121:15), at Runtime.main [as handler] (/var/task/index.js:200:20), at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1306:29)] [21178bd3-a207-43d1-a635-daa3c3cbfc35]",
"code": "INTERNAL_SERVER_ERROR",
"status": 500,
"messageParams": {},
"details": [],
"errors": []
}
]
}
------------------------------
Xavier Vincent
------------------------------
Original Message:
Sent: 12-12-2025 10:06
From: Gregory Cunningham
Subject: Passing HTTP return codes from Genesys Cloud Function
Hi Xavier,
When you run the Function DataAction in the Admin UI in TEST mode, what is the response?
From what you are describing for your return, you are just returning a body that has an error code it it. That is not considered and error. Only failing your function with an error via a throw is going to result in an error. Using test mode should be able to confirm this is what is happening.
Here is an example of what one of our test Functions returns when given a shouldThrow = true argument:
{
"message": "Internal Server Error",
"code": "internal.server.error",
"status": 500,
"messageParams": {},
"contextId": "7e09e985-f217-4076-9119-d3f6046a1129",
"details": [
{
"errorCode": "ACTION.REMOTE_ENDPOINT"
}
],
"errors": [
{
"message": "REST call for action execute failed. Message: Invoked function failed. Response from function: Function execution failed with error Type: Unhandled; Message: errorType:Error,errorMessage:Error message,trace:[Error: Error message, at createResponse (/var/task/src/index.js:111:19), at Object.<anonymous> (/var/task/src/index.js:98:39), at step (/var/task/src/index.js:32:23), at Object.next (/var/task/src/index.js:13:53), at /var/task/src/index.js:7:71, at new Promise (<anonymous>), at __awaiter (/var/task/src/index.js:3:12), at exports.handler (/var/task/src/index.js:61:64), at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1306:29)] [7e09e985-f217-4076-9119-d3f6046a1129]",
"code": "INTERNAL_SERVER_ERROR",
"status": 500,
"messageParams": {},
"details": [],
"errors": []
}
]
If your are going to be returning a body that might have an error code in it, then you will have to handle that as branching in Architect based on the return value in the body of our response.
I hope this clarifies things. I'll monitor of your reply if you have further questions.
------------------------------
Gregory Cunningham
Software Architect
------------------------------