Access body object from webhook from nocodb?

I am trying to get access to the info that I get back from a webhook post from nocodb. It seems to give me invalid json styling and I can’t figure out how to get into the body and access the other objects to use to send a message.

Here is the json I get from the incoming webhook into a code block, but ideally I would like to post it as a discord message.


[
{
"headers":
{
"host":
"n8n.blackhole.earth",
"user-agent":
"axios/0.21.4",
"content-length":
"1540",
"accept":
"application/json, text/plain, */*",
"accept-encoding":
"gzip",
"cdn-loop":
"cloudflare",
"cf-connecting-ip":
"98.97.118.61",
"cf-ipcountry":
"US",
"cf-ray":
"7c2275d4fbea086d-SEA",
"cf-visitor":
"{"scheme":"https"}",
"cf-warp-tag-id":
"40c68f68-7b2a-48fb-9715-623d45019fa4",
"connection":
"keep-alive",
"content-type":
"application/x-www-form-urlencoded",
"x-forwarded-for":
"98.97.118.61",
"x-forwarded-proto":
"https"
},
"params":
{
},
"query":
{
},
"body":
{
"{"type":"records.after.update","id":"40453db7-0834-4650-b33e-12eb14dcb3d4","data":{"table_id":"md_01cw5c2lijiat4","table_name":"Event-Calendar","view_id":"vw_vdg4pgiwn6co0g","view_name":"Event-Calendar","previous_rows":[{"Id":1,"Title":"DSARC Meeting","CreatedAt":"2023-05-04T00:09:02.839Z","UpdatedAt":"2023-05-04T17:28:26.343Z","Start Time":"2023-06-06T19:00:12.000Z","End Time":"2023-06-06T20:30:28.000Z","Event Site":"https://dsarc.us","Image":[{"path":"download/noco/DSARC/Event-Calendar/Image/e2YzjDyKq7EHMULHI_.png","title":"hamshackhotline_logo.png","mimetype":"image/png","size":92659}],"Description":"Monthly meeting","Contact Email":"[email protected]","Contact Phone":"208-346-2202","Submitter Name":"John Doe","Submitter Callsign":"KJ7DOE","Submitter Email":"[email protected]","Address":"Some Landmark","City":"Some Town","State":"TX","Zip":"12345","Approved":"No"}],"rows":[{"Id":1,"Title":"DSARC Meeting","CreatedAt":"2023-05-04T00:09:02.839Z","UpdatedAt":"2023-05-04T17:28:27.482Z","Start Time":"2023-06-06T19:00:12.000Z","End Time":"2023-06-06T20:30:28.000Z","Event Site":"https://dsarc.us","Image":[{"path":"download/noco/DSARC/Event-Calendar/Image/e2YzjDyKq7EHMULHI_.png","title":"hamshackhotline_logo.png","mimetype":"image/png","size":92659}],"Description":"Monthly meeting","Contact Email":"[email protected]","Contact Phone":"208-346-2202","Submitter Name":"John Doe","Submitter Callsign":"KJ7DOE","Submitter Email":"[email protected]","Address":"Some Landmark","City":"Some Town","State":"TX","Zip":"12345","Approved":"Yes"}]}}":
""
}
}
]

Hi @av8, welcome to the community :tada:

We can hopefully figure this one out, though it seems some information not shown in the UI might have gotten lost when you copied this JSON data. Can you copy it once more, this time using the button shown below to keep all formatting and include all control characters you might have? The button will only appear once you hover over your JSON data:

image

You can of course redact any confidential values you might have in your JSON data, I am just interested in its structure (so the structure itself would have to stay intact).

Thanks for helping with this.

Here is the input that I am getting. From the webhook trigger. I don’t have an output yet because I am trying to get into the discord action. That said when I try in a code block the only output I can get to actually work is the same as the input. Anytime I try to work my way into the response I get an error.

[
  {
    "headers": {
      "host": "n8n.blackhole.earth",
      "user-agent": "axios/0.21.4",
      "content-length": "1540",
      "accept": "application/json, text/plain, */*",
      "accept-encoding": "gzip",
      "cdn-loop": "cloudflare",
      "cf-connecting-ip": "98.97.118.61",
      "cf-ipcountry": "US",
      "cf-ray": "7c2275d4fbea086d-SEA",
      "cf-visitor": "{\"scheme\":\"https\"}",
      "cf-warp-tag-id": "40c68f68-7b2a-48fb-9715-623d45019fa4",
      "connection": "keep-alive",
      "content-type": "application/x-www-form-urlencoded",
      "x-forwarded-for": "98.97.xxx.xxx`Preformatted text`",
      "x-forwarded-proto": "https"
    },
    "params": {},
    "query": {},
    "body": {
      "{\"type\":\"records.after.update\",\"id\":\"40453db7-0834-4650-b33e-12eb14dcb3d4\",\"data\":{\"table_id\":\"md_01cw5c2lijiat4\",\"table_name\":\"Event-Calendar\",\"view_id\":\"vw_vdg4pgiwn6co0g\",\"view_name\":\"Event-Calendar\",\"previous_rows\":[{\"Id\":1,\"Title\":\"DSARC Meeting\",\"CreatedAt\":\"2023-05-04T00:09:02.839Z\",\"UpdatedAt\":\"2023-05-04T17:28:26.343Z\",\"Start Time\":\"2023-06-06T19:00:12.000Z\",\"End Time\":\"2023-06-06T20:30:28.000Z\",\"Event Site\":\"https://dsarc.us\",\"Image\":[{\"path\":\"download/noco/DSARC/Event-Calendar/Image/e2YzjDyKq7EHMULHI_.png\",\"title\":\"hamshackhotline_logo.png\",\"mimetype\":\"image/png\",\"size\":92659}],\"Description\":\"Monthly meeting\",\"Contact Email\":\"[email protected]\",\"Contact Phone\":\"208-346-2202\",\"Submitter Name\":\"John Doe\",\"Submitter Callsign\":\"KJ7DOE\",\"Submitter Email\":\"[email protected]\",\"Address\":\"Some Landmark\",\"City\":\"Some Town\",\"State\":\"TX\",\"Zip\":\"12345\",\"Approved\":\"No\"}],\"rows\":[{\"Id\":1,\"Title\":\"DSARC Meeting\",\"CreatedAt\":\"2023-05-04T00:09:02.839Z\",\"UpdatedAt\":\"2023-05-04T17:28:27.482Z\",\"Start Time\":\"2023-06-06T19:00:12.000Z\",\"End Time\":\"2023-06-06T20:30:28.000Z\",\"Event Site\":\"https://dsarc.us\",\"Image\":[{\"path\":\"download/noco/DSARC/Event-Calendar/Image/e2YzjDyKq7EHMULHI_.png\",\"title\":\"hamshackhotline_logo.png\",\"mimetype\":\"image/png\",\"size\":92659}],\"Description\":\"Monthly meeting\",\"Contact Email\":\"[email protected]\",\"Contact Phone\":\"208-346-2202\",\"Submitter Name\":\"John Doe\",\"Submitter Callsign\":\"KJ7DOE\",\"Submitter Email\":\"[email protected]\",\"Address\":\"Some Landmark\",\"City\":\"Some Town\",\"State\":\"TX\",\"Zip\":\"12345\",\"Approved\":\"Yes\"}]}}": ""
    }
  }
]
1 Like

Thank you, this helps a lot with understanding the data you have! It looks like your specific webhook comes through with a very unusual body. The data you’re interested in is sent as a JSON key, with an empty string as the value. I believe NocoDB lets you configure the webhook format, so you might want to check with their community/support team how to fix this before sending.

However, assuming you can’t change this format, you could parse it with a little bit of code including Object.keys() (since the actual name of your key is changing) and JSON.parse() (to actually parse the data). This is how it would look in a workflow:

This is the result:

Hope this helps :slight_smile:

2 Likes

That did it for me. Thanks so much for your help, there was a lot of hair pulling on this. I will check with the noco community as well.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.