Issue with JSON Structure in Webhook Configurations for list of strings

I need to pass an array of strings into my Webhook body. I’m trying to use a JSON structure in my Webhook API request with “values”: geo_ids where geo_ids is an array of strings like [“3889330”, “3703328”, “3709403”, “3711041”, “3789423”, “3762202”, “3711811”, “3740228”, “3867349”, “3731856”].

However, I’m encountering an issue but can’t identify the problem based on the documentation for how to pass a list of items in. Can anyone help me understand what might be going wrong or if there’s a specific format or requirement I’m missing for this API endpoint?

The workflow that triggers the webhook is:
A workshop button triggers an action (passing a couple of variables including geo_ids) → then the action takes those variables and inputs them into the json as parameters.

The body that works and has been tested is:
{
“day_id”: 2900,
“resource_filters”: [
{
“filter_key”: “trip_intersects”,
“values”: [
“3889330”,
“3703328”,
“3709403”,
“3711041”,
“3789423”,
“3762202”,
“3711811”,
“3740228”,
“3867349”,
“3731856”
] // this array for trip intersects values is what i am referring to as geo_ids
},
{
“filter_key”: “primary_mode”,
“values”: [
“WALKING”,
“BIKING”
]
}
],
“origin_geo_layer_id”: 6622,
“destination_geo_layer_id”: 6622
}

TY

1 Like

What documentation are you looking at and what API are you trying to call? It would help if you could reference the explicit names used in the product for the workflow you are trying to configure.

Documentation references:

  • https://www.palantir.com/docs/foundry/functions/external-sources/#use-webhooks-in-functions
  • https://www.palantir.com/ docs/foundry/data-connection/webhooks-reference/

I’m using the Webhook Data Connection to hit a private api within our company.
I was kind of able to pinpoint the issue. So the webhook has been configured to accept a list of strings (array of strings) as a parameter.
But when i pass an array of strings through the action to call the webhook, it is reformatted to have extra quotes and back slashes which can be seen in the webhook history. Do you know how to pass a list of strings through a workshop action with the correct format?

As another test, I built a function that calls the webhook and it successfully returns a response from the webhook in the function previewer, but the function fails in workshop.

1 Like

We resolved this by parsing the array input from workshop in a function

@Query()
    public async callODPairsWebhook(dayId: Integer, geoIds: string[]): Promise<string> {
        const input = { 
            "day_id": dayId,
            "geo_ids": geoIds.map(x => JSON.parse(x))
        }
        const result = await Sources.CdsProd.webhooks.OriginDestinationCounts.call(input);

        if (isOk(result)) {
            let output = result.value.output['origin-destination-counts'];
            let jsonData = JSON.parse(output)

            if (jsonData.data.length > 5) {
            output = jsonData.data.slice(0, 5);
            }
            console.log('Success: ', output)
            return JSON.stringify(output)

        } else {
            console.log('Error calling webhook: ', result.error)
            return result.error.message
        }
    }