Help

Re: Get the body of a webhook's payload

1110 0
cancel
Showing results for 
Search instead for 
Did you mean: 
insightautomate
4 - Data Explorer
4 - Data Explorer

I have an automation triggered by an incoming POST web hook.

I do not have control over the format of this workbook however it send its content as a JSON whose structure can vary but at the top level contains a key "data" which is an array of objects each containing information about a particular answer in a form response.

e.g 

{
  "data": [
    {
      "title": "What survey/inspection would you like?",
      "description": null,
      "type": "choices",
      "key": "d747n",
      "custom_key": null,
      "value": "Level 1 Health Check"
    },
    {
      "title": "",
      "description": null,
      "type": "hidden",
      "key": "4pf996l",
      "custom_key": "age",
      "value": "4"
    },
    {
      "title": "",
      "description": null,
      "type": "hidden",
      "key": "9b8fc",
      "custom_key": "cost",
      "value": null
    }
]
}

This means that the when trying to use the data in a script using inputConfig it wants to create a list of values e.g a list of all "custom_keys" or all "types"... not helpful. Moreover it can't actually create a list of the values for the key "value" as it says

"Cannot assign list of collection of complex types to collection of complex types"

Is there no way to simply get the full payload of a webhook as a variable for my script beyond using some external service to serialize it and then parse  in the script?

5 Replies 5

I thought I may have been able to help with this one, but then found the exact same limitation - we can't simply import the body as an object into a scripting action.

Then I thought, I might try out the recently released Repeating Group action to process your data as a list, but it again hits similar issues, as per the below screenshot.

Karlstens_0-1679123032709.png

"Cannot assign list of collection of complex types to collection of complex types"

This is worth raising as a feature request with Airtable, I dare say it must have been requested countless times already. I've always had the luxury of writing my own Post requests, so haven't hit this problem before.

 

Katieglamer
5 - Automation Enthusiast
5 - Automation Enthusiast

Hiya, not sure if my response is helpful, but thought I would share as I have also been trying to get around this, it's very annoying. In the end I just sent my data as a massive string and split it on the receiving side with a script.

Where previously my data for each clash looked the same as yours:

e.g.:

 

{
'name': 'Katie',
'date': '12th Oct 2023',
'job': 'This is the name of a job'
},
{
'name': 'Katie',
'date': '12th Oct 2023',
'job': 'This is the name of a job'
}

 

 
I just concatenated it into a string like:

 

let clashes = "Katie, 12th Oct 2023, This is the name of a job, Katie, 12th Oct 2023, This is the name of a job"

 

and then sent it like this:

 

method: 'POST',
    body: JSON.stringify({"clashes": clashes}),
    headers: {
        'Content-Type': 'application/json',
    },

 

Then you can access everything at once 😊

Katieglamer_0-1697069383228.pngKatieglamer_1-1697069428462.png

I will split by "," and deal with the array.

Not cleanest solution, but it's worked for me 🙂

William_Nutt
6 - Interface Innovator
6 - Interface Innovator

Very much hoping Airtable will add support for accessing the raw JSON.

lizapolyudova
4 - Data Explorer
4 - Data Explorer

Something I've done in the past is go to "run history" and use developer tools > network tab to get JSON for the specific message. If you open up a specific automation call, you'll see calls to 

 

https://airtable.com/v0.3/workflowExecution/{workflow_ID}/read?. .. labelled  in developer tools as read?..

The first two request (at least for me) are the test data used by the workflow. The last request actually contains the json blob of the incoming webhook call. Hope this helps

Screen Shot 2023-12-27 at 12.28.56 PM.png

That's what i was looking for. Thank u 😍