Receiving webhook with array of objects. Bug or not supported?

Don’t know if this is a bug, not supported or needs a workaround.

I am receiving an array of objects on the root. When I console.log on the server $_POST I can see it’s indeed [{},{},…] but when I want to save the result directly into DB it will open and close curly brackets and stringify the objects inside the array. So it will save {“stringified objects”}.

Is there any way to pass directly the array to the DB?

Sample of response.

[
  {
    "email": "example@test.com",
    "timestamp": 1513299569,
    "smtp-id": "<14c5d75ce93.dfd.64b469@ismtpd-555>",
    "event": "processed",
    "category": "cat facts",
    "sg_event_id": "sg_event_id",
    "sg_message_id": "sg_message_id"
  },
  {
    "email": "example@test.com",
    "timestamp": 1513299569,
    "smtp-id": "<14c5d75ce93.dfd.64b469@ismtpd-555>",
    "event": "deferred",
    "category": "cat facts",
    "sg_event_id": "sg_event_id",
    "sg_message_id": "sg_message_id",
    "response": "400 try again later",
    "attempt": "5"
  }
]

If I use the above result as a test value in the query it will save correctly into the jsonb PG field.

Community Page
Last updated: