Webhook Not Inserting into DB

I’m trying to use webhooks to get some data into my database.
But it never gets into my DB.

https://webhook.site says this is what is being sent:

“envelope”: {
“to”: “afc1db9288e596eae297@cloudmailin.net”,
“recipients”: [
afc1db9288e596eae297@cloudmailin.net
],
“from”: “mail@mailaddress.comt”,
“helo_domain”: “smtp01-smtp-0.daemonmail.net”,
“remote_ip”: “216.104.162.130”,
“tls”: false,
“tls_cipher”: null,
“md5”: “217a4522ec0b13619a16acc6cd47f973”,
“spf”: {
“result”: “none”,
“domain”: “mailaddress.com
}
},
“plain”: “This is a test email!”,

I made a server action under webhooks.
I don’t know much about webhooks. I examined @mebeingken forum posts about it from back in 2019. It was a bit helpful but obviously something is still wrong.
In there I made a Database Insert. It looks like this:

This is the place that is sending me the data.
When I use the Webhooks server action it gets a 200 response… but nothing ever gets inserted into my database. That’s the problem.

I tried basically doing the same thing in the API section and that gave me a 500 response.

Any help?
THANK YOU!
Jeff

I’d focus on using a regular api for now.

Check the details of your 500 error so you can troubleshoot.

I’d like to do that, but the service I’m using only does webhooks.

Right, but that webhook just needs a url. You can point it to yourdomain/dmxConnect/api/api-name (or yourdomain/api/api-name for node.)

You’re right. I do have the webhook pointed at http://mydomain.com/folder/dmxConnect/webhooks/CheckAndParseEmail.php

The place sending me the data will give a 200 response when I use the webhook action file in Wappler and do a database insert. But, if I use an api action file and do a database insert it gives a 500 response. (see photo above)

Anyway, even though it gives a 200 response when hitting the webhook action file .php page, and seems good, the data doesn’t get into my database.

A webhook is nothing more than a reverse api. It just posts data to an endpoint. So all you have to do is create an api to consume the data the webhook sends.

The Wappler webhook section has not been documented beyond Stripe afaik, and because that Stripe integration is expecting very specific callbacks, it works nicely.

So I’m suggesting you just use an api endpoint as that has a very clear path to success, at least until somebody with more knowledge than me replies.

Most every 500 error comes with a very detailed explanation if you have turned on the server connect debugging for your project. It typically would be available to you when testing the webhook.

Now, if you really think the webhook way of consuming is working but just not inserting properly, perhaps you are pointing to the wrong post variables syntax? You could use a set value of $_POST to output everything in order to find the proper object paths.

“all you have to do is create an api to consume the data the webhook sends”

Maybe that’s where I’m confused. I don’t know how to make an api.
Or do you mean an api action file in Wappler? If I do that what would I set the URL to?

Exactly. To find the url, just use the Open in Browser icon and see what is in the url bar.

You mean I can set the api link back to my own address for the api file itself?
I just figured that would create an infinite loop and destroy the world or something.

I don’t know all the details of what you are doing. :slight_smile: but as far as the webhook is concerned, you create a new api server action, whose only purpose is to consume the data sent by the webhook.

Ken, I’m so sorry. I’m just not getting it. :man_shrugging:
Could you walk me through one step at a time how you’d do this? 'Cause I tried setting the link to the new api server action… creates a loop… I’m really missing something.

The documentation is here: https://docs.cloudmailin.com/http_post_formats/json_normalized/

  1. You’d create a new api action file.
  2. In that action file you’d create an an API action step, right?
    How would you define those values?

Then how do you grab that and put it in your DB?

Hey @sophos707 - I think this post might help you:

Ignore that it’s for Stripe, but within this post max_gb talks about how to create the webhook/endpoint and the variables that Stripe then sends into. this is essentially how to setup a Webhook using the API Action in SC.