Post with array input cannot have lambda in function stack?

Options
JG
JG Member

I have a POST endpoint that is ingesting webhooks from a third party (wrike). The payloads are a single array like this:
[
{
"title": "Follow up on status of RFI with Architects",
"taskId": "IEACIWZSKQZGQVIU",
"oldValue": "Follow up on status of RFI with Architect",
"eventType": "TaskTitleChanged",
"webhookId": "IEACIWZSJAABNRYU",
"eventAuthorId": "KUAEW7KF",
"lastUpdatedDate": "2023-03-05T20:48:17Z"
}
]

When anywhere in my stack i try to do a lambda step, i get the following error: ["$input must be an object"].

My lambda code is not part of the error, i've set the code to: return "John Doe";.
It seems like the lambda is expecting the $input parameter to always contain an object, which is not always the case with webhooks.

Is there any way to fix this?

Tagged:

Answers

  • arturosanz
    arturosanz Member ✭✭
    Options

    Why don't you check first if the "Get All Input" result is an object or not with the filter "is_object". If it is false, just create an object containing whatever the result was. Then do the lambda step.