Webhook JSON header require Content-Type:application/json. Otherwise fail

Hi bubblers, I need some quick reference/help.

I have a bubble api webhook that receives a JSON post from another server notifying me of payments.

Their JSON message is in the standard JSON format as shown below.

{
“header”:{
“sig”:“2kOUGU034ewgyWSetc=”,
“timestamp”:“2019-08-20T08:31:47.1938912Z”
},
“body”:{
“payerbanknum”:“ABCDEF”,
“payerbankname”:“XYZ”,
“billerbanknum”:“ETC”,
“billerbankname”:“XXX BANK”,
“currencycode”:“MYR”,
“amount”:400,
“extdata”:null
}
}

What I noticed is that this message is not properly recognised by my bubble webhook when I received their test message.

I therefore tested this JSON message using Postman (Chrome) and found that the following is interpreted by Bubble during initialization detection:

{
“body”: "{\n “payerbanknum”:“ABCDEF”,\n “payerbankname”:“XYZ”,\n “billerbanknum”:“ETC”,\n "billerbankname …

if I inserted “Content-Type”:“application/json” in the header, the problem disappears and the following is correctly detected:

{
“body”: {
“payerbanknum”: “ABCDEF”,
“payerbankname”: “XYZ”,
“billerbanknum”: “ETC”,

It therefore implies that Content-Type must be added to the JSON Post for bubble to recognise the message properly.

As I cannot tell the sender to change their JSON message and to include “Content-Type” in the header, is there any way I can get this to work in my webhook?

2 Likes

I think that you, sadly, really need to ask sender to set their header. Bubble cannot guess the content-type. While some will send Json, some other may use multiform data or url encoded.

Did you try to configure manually the Parameters? Not sure this will help.
Maybe there’s a few workaround. (example, you receive it as it, and foward it to another API Workflow with the correct header)

Thanks for your quick reply. I am at present coordinating for another test from the sender. I could not intercept their test message when they first sent as the timing was not preadvised. I was sent the format of the JSON only - it was then I noticed that the header included only “sig” and “timestamp” excluding “content-type”.

I have manually confirmed by using Postman in Chrome that JSON without Content-Type will be interpreted incorrectly.

If it is true that the sender has not included Content-Type and will not change it just for me, is there a work around?

Example work around: Have bubble assume that all POST message sent to my endpoint be assumed to be of the type “application/json” by default? Is there anyway to do that?

For what I know it’s not possible.
The workaround I suggest is to use initialy the auto-detect feature. Not sure how Bubble will interpret that, but maybe it will be put as a text in one var that will contain all the json.
Now, What if you create an API Connector that will point to another API Workflow.
When the initial POST is made, Use this API Connector to redirect Data to the second API Workflow, but now, with the content type header.
I’m not sure this will work, but if Bubble just consider the json into one parameters on the initialize call, this should work.

I have now used initialize auto detect in bubble to capture the JSON that was sent. It looks as follows:

{
    "body": {},
    "headers": {
        "x-forwarded-host": "eazisearch.bubbleapps.io",
        "x-forwarded-proto": "https",
        "x-forwarded-port": "443",
        "x-forwarded-for": "::ffff:110.74.140.46",
        "connection": "Keep-Alive",
        "expect": "100-continue",
        "content-length": "497",
        "host": "eazisearch.bubbleapps.io",
        "content-type": "text/json"
    }
}

As you can see the body is empty.

When I enquired with the senders technical team as to why the JSON body is empty, the reply I received from the sender is as follows:

Your JSON message is referring to HTTP header. All the key information will be in the HTTP body which consist of request header and request body.

Below is the request message that we sent yesterday.

{“header”:{“sig”:“xVf57bzYWGVuemqdrY09jhl=”,“timestamp”:“2019-08-27T07:04:40.0896945Z”},“body”:{“payerbanknum”:“8000088”,“payerbankname”:“ABC BANK”,“billerbanknum”:“80000986”,“billerbankname”:“ABC BANK”,“accounttype”:“2”,“billercode”:“9000”,“billercodename”:“XYZ Sdn Bhd”,“nbpsref”:“AB9020”,“channel”:“3”,“currencycode”:“MYR”,“amount”:100,“extdata”:null}}

I must admit that I am a total novice in JSON. I would be grateful if anyone can explain to me what they are trying to say. As I am concerned Bubble has not recognised the message that they sent in the HTTP body.

Is there anything that I can do to resolve this problem of bubble not recognising all the JSON post?

Thanks.

Hi all. Is this a problem any fellow bubblers have ever faced? Is this a problem from the sender side or is it something I can work around. @neerja can experts from your team explain/help.

The issue seem more to come from the other app than bubble. I believe they dont encode this correctly. I will check for a workaround

Are you able to get at least tbe raw data that is in the email?like in your first post

No I cannot get the data formatted like in the email.

Bubble only detected the below (raw source).

{
    "body": {},
    "headers": {
        "x-forwarded-host": "eazisearch.bubbleapps.io",
        "x-forwarded-proto": "https",
        "x-forwarded-port": "443",
        "x-forwarded-for": "::ffff:110.74.140.46",
        "connection": "Keep-Alive",
        "expect": "100-continue",
        "content-length": "497",
        "host": "eazisearch.bubbleapps.io",
        "content-type": "text/json"
    }
}

I have now used another website RequestBin.com to capture the entire JSON message from the sender and this is what I got:

Header section

host: enasp2dsacfws.x.pipedream.net
content-type: text/json
content-length: 497
connection: keep-alive 

In the body is the following JSON text:

{
    "header": {
        "sig": "9jvvt9098ipjiasdfasdkfsnUtVhwMBRA=",
        "timestamp": "2019-09-05T08:15:30.4208582Z"
    },
    "body": {
        "payerbanknum": "10000.....",
        "payerbankname": "XXXX BANK",
        "billerbanknum": "10000.....",
        "billerbankname": "XXXX BANK",
        "accounttype": "X",
        "billercode": "6XXXX",
        "billercodename": "XXXXX Sdn Bhd",
        "nbpsref": "699092M7",
        "channel": "1",
        "debittimestamp": "2019-09-05T08:15:28.0000000+00:00",
        "repeatmsg": "N",
        "rrn": "12345678901",
        "rrn2": "",
        "currencycode": "MYR",
        "amount": 20000,
        "extdata": null
    }
}

This looks like a properly formed JSON message. Can any bubble experts help me figure out why the JSON message is not recognised / accepted by bubble Webhooks initialise as experienced in my previous post in this same thread? @Jici @neerja and other bubblers, I would be really grateful if you can assist.

Normally, the header should not be text/json but application/json. This is probably why Bubble doesn’t detect it.

If you can find a permanent solution inside bubble, you could try Integromat to see if their webHook can extract the data that you need. You can can then create a http post from Integromat to bubble with correct the json header.

1 Like

Integromat have an option that will let you just redirect the whole body to Bubble API Endpoint.
You create the webhook in Integromat and use advanced setting to set json-passthrough

This topic was automatically closed after 70 days. New replies are no longer allowed.