Webhook receiving raw JSON

When I’m testing my webhooks from Postman, I do JSON body.

That’s what I meant…added to Globals section.

You can always set {{$_POST}} to a value for output and see exactly what is coming for troubleshooting.

Thanks for all your help, @mebeingken. It’s very much appreciated.

Using Postman I have successfully sent some JSON to the webhook and it’s worked fine so it’s looking like Stripe is sending the data in a non-standard way. Hard to believe, though. I will do some more tests with Stripe and see if I can get to the bottom of it. I’ll probably phone them tomorrow.

1 Like

OK, I’m getting somewhere.

I’ve told Stripe to send the JSON to a webhook.site URL so I have all the output.

I’ve copied and pasted that output into Postman and sent it to my webhook.

No data is inserted.

I’ve removed lots of the JSON so it’s down to about a dozen variables and it’s inserting the data perfectly.

So, bizarrely, it looks like Stripe’s data is too big for my Wappler webhook to handle. Either that or there’s a rogue variable name which is causing problems and the only way to find out is to remove them one at a time and keep trying.

Very odd.

Or perhaps there is a character your database doesn’t like???

EDIT: Or is that what you mean by “rouge variable”?

Yep, something in amongst the data isn’t liked by my database or script. I’m removing bits and trying to see if I can find what it is. Fixing it will be hard, though, as I can’t tell Stripe not to sending something!

I always go with UTF-8 db tables and haven’t seen any issues like this. If the POST is coming in, you might be able to search/replace if you can nail down the culprit or can’t change your table schema.

1 Like

I’ve found the rogue field!

“paid” : true,

I had my field set as TINYINT(1) but it doesn’t seem to like receiving a true / false result. It doesn’t make a difference if I ignore that field (eg. don’t insert it into the database at all), it seems to object to it being sent in the JSON in the first place.

Don’t quote me here, but wouldn’t that still make sense? The schema for your insert is probably included in the action, and even though you are no longer inserting that field, it might drop out if it feels there is a mismatch in the schema. Just guessing here.

EDIT: Not sure I believe my own statement here!

Should be able to just convert your true to 1 and move on. Sounds like you are getting close!

I’ve removed that field from the schema and the data is now inserting when sent from Postman. BUT, the exact same data sent from Stripe inserts a record with null values in all the fields.

This is driving me nuts! It’s now midnight here so I think I’m going to come back to it tomorrow.

A fresh day will definitely help…it always does. :slight_smile:

1 Like

Do you know where I would put some code in to convert true/false to 1/0 ?

I’d probably first try a ternary in the value column of your insert.

{{$_POST.badfield == true ? 1 : 0}}
1 Like

That’s now inserting 0 but because it’s not receiving any data. Bizarre that the JSON from Stripe is resulting in a record insert with all null fields (apart from the ‘paid’ field which now has a 0 because of that conversion code) but if I copy and paste the exact JSON that Stripe sent into Postman and post that, it works! And that includes the ‘paid’ field which is now storing 1.

There’s something in the way Stripe sends the JSON which is not liked.

I’ll come back to this tomorrow.

Huge thanks again, you’ve been an absolute star, @mebeingken.

1 Like

A new morning, a fresh head!

I’ve gone through checking the headers sent using webhook.site and have found the offending one.

Stripe sends this:
Content-Type: application/json; charset=utf-8

Postman sends this:
Content-Type: application/json

When I add charset=utf-8 into the headers, the data is inserted with null fields.

The collation on all my text fields is:
utf8_general_ci

So I would really appreciate some guidance on how to get my webhook script to accept the data as utf-8 and insert it correctly.

@patrick - are you able to assist me?

I’m at a loss as to how to fix this. I’ve finally found the issue but no idea how to resolve it (see previous post).

Can anyone help?

@George - are you able to help here?

do you need to send raw json data @mebeingken , @sitestreet ?

Raw is the only json I have ever tried.

1 Like

can you show me correct format ?

For something specific, or generic? I posted a json sample above for plaid if that helps.