Help with JSON coming in through webhook

So, I tried posting this earlier and not sure I did it right with the code.

The JSON coming in through the webhook isn’t being automatically recognized so I can use it.

When I go to grab the information it’s all showing as one big string. Any ideas?

Here’s the output bundle that is coming.

[
    {
        "{\"Form ID\":1,\"Form Title\":\"Get A Cash Offer Today!\",\"Entry ID\":\"65\",\"Entry Date\":\"November 16, 2023 at 7:36 am\",\"User IP\":\"71.218.142.149\",\"Source Url\":\"https:\\/\\/www.trueblueoffers.com\\/\",\"Created By\":\"\",\"Transaction Id\":\"\",\"Payment Amount\":\"\",\"Payment Date\":\"\",\"Payment Status\":\"\",\"Post Id\":\"\",\"User Agent\":\"Mozilla\\/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/118.0.0.0 Safari\\/537.36\",\"Session ID\":\"\",\"Lead state\":\"\",\"Lead Source\":\"facebook.com\",\"Property Address (Street Address)\":\"3300 S Tamarac Dr\",\"Property Address (Address Line 2)\":\"\",\"Property Address (City)\":\"Denver\",\"Property Address (State \\/ Province)\":\"Colorado\",\"Property Address (ZIP \\/ Postal Code)\":\"80231\",\"Property Address (Country)\":\"United States\",\"Property Address\":\"3300 S Tamarac Dr Denver Colorado 80231 United States\",\"Phone\":\"1 (303) 555-5555\",\"Email\":\"united70000033@yahoo.com\"}": ""
    }
]

Hello Terry, i believe that, you have to change “JSON parse-through” to No, as shown below:

2 Likes

Thank you for responding!

That setting is set to no right now. I’ve actually tried both and it’s still the same thing.

Hey @Terry_Ruch , so most likely the system who send this data is not setting the “content-type” header properly. Either you would have to modify this header if you can, or you can use the “JSON” module and use the “Parse JSON”.

Hope this helps you !

2 Likes

Hi @Terry_Ruch,

It looks like the output bundle isn’t actually valid JSON (checked when pasted into https://jsonformatter.org).

You can tell by the fact that the key (in red) contains the entire “payload” (data), and the double quotes are escaped. The value (in green) of that key contains an empty string, which is where your data/collection goes:

So this advice is incorrect, and you cannot even use a “Parse JSON” module to convert that into a collection.

You should contact the external service to get this bug fixed.

2 Likes

@samliew this stringified JSON output is what you get when you check the output within Make of a webhook module. This is a make thing…
if you look at the screenshot you can see the data looks OK and it ends at the last } so probably a typo :wink:

@Terry_Ruch Can you double check the JSON and then try the parser? See what happens?

2 Likes

OK, so after digging into this more it looks like the application type is `application/x-www-form-urlencoded. It’s a zapier integration inside of Carrot which is a website program for real estate investors.

Is there anyway to transform this for Make.com? When I use the Parse json module, I get the error

BundleValidationError

Validation failed for 1 parameter(s).

  • Missing value of required parameter ‘json’.

I’m not even sure if I’m using Parse json correctly but it did go and grab and recognize all the different items in the generator. It just errors when I try to run it.

Like I said earlier, that is not JSON and you CANNOT use the “Parse JSON” module for this (at least not directly). The server is basically saying this is not JSON by sending the content type header as “application/x-www-form-urlencoded”. A JSON response would contain something like “application/json”. I said: This is actually a bug on the external service and should be reported to them.

What you can do, is try to set the “JSON pass-through” field to YES. This can only can be done when creating/setting up the webhook, so you can delete the existing one you’ve got.

Only after this has been done, you can try using the Parse JSON module with the body/data output.

2 Likes

Yes so the data you receice is not formatted correctly and has the wrong headers. Try this;

  • enable json passthrough on the webhook
    You can do this underneath the menu item Webhooks → find the webhook → Edi
    You don’t need to delete youe webhook at all

  • use a regex pattern and search for the parts you want to remove, so in this case you only want to end up with the JSON data so you can parse it later. How to use Regex in Make?
    You can use the replace() function to replace parts with an emptrystring (remove the parts you don’t need).

  • use the JSON parser module and parse out the data you are left with

It does require a bit of effort, so ideally you want to fix the side of the input. If you can modify system which sends this data, that would be the best way

2 Likes

Wow. That’s amazing! So what would be the pattern to pull out the phone and email of this string?

{"Form ID":1,"Form Title":"Get A Cash Offer Today!","Entry ID":"59","Entry Date":"November 15, 2023 at 1:53 pm","User IP":"76.154.144.144","Source Url":"https:\/\/www.trueblueoffers.com\/","Created By":"","Transaction Id":"","Payment Amount":"","Payment Date":"","Payment Status":"","Post Id":"","User Agent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/118.0.0.0 Safari\/537.36","Session ID":"","Lead state":"","Lead Source":"(direct)","Property Address (Street Address)":"3439 Decatur St","Property Address (Address Line 2)":"","Property Address (City)":"Denver","Property Address (State \/ Province)":"Colorado","Property Address (ZIP \/ Postal Code)":"80211","Property Address (Country)":"United States","Property Address":"3439 Decatur St Denver Colorado 80211 United States","Phone":"1 (303) 555-5555","Email":"united70034@yahoo.com"}