How to send JSON from macro to Make.com – how to fix the `Unexpected token c in JSON at position 17` error?

Thanks to this awesome community for creating these Plug In Actions:

I would like an Plug In Action for Make.com too. However I don't know how to create one.

The goal for me is to send JSON from a macro to a Make.com webhook. This is the JSON that I would like to send to the Make.com webhook:

[
  {
    "clickRate": "42.5%",
    "emailId": "1000001",
    "emailName": "Boost Your Productivity with AI Tools",
    "openRate": "80.1%",
    "sends": "5,254",
    "sequenceId": "300001",
    "unsubscribers": "455"
  },
  {
    "clickRate": "5.7%",
    "emailId": "1000002",
    "emailName": "Cloud Storage: The Future of Data Management",
    "openRate": "57.6%",
    "sends": "3,543",
    "sequenceId": "300001",
    "unsubscribers": "362"
  },
  {
    "clickRate": "0%",
    "emailId": "1000003",
    "emailName": "5 Cybersecurity Tips to Protect Your Business",
    "openRate": "54%",
    "sends": "3,158",
    "sequenceId": "300001",
    "unsubscribers": "197"
  },
  {
    "clickRate": "0.8%",
    "emailId": "1000004",
    "emailName": "How 5G is Transforming Connectivity",
    "openRate": "50%",
    "sends": "2,947",
    "sequenceId": "300001",
    "unsubscribers": "132"
  },
  {
    "clickRate": "0.6%",
    "emailId": "1000005",
    "emailName": "Understanding Blockchain Technology",
    "openRate": "49.6%",
    "sends": "2,798",
    "sequenceId": "300001",
    "unsubscribers": "68"
  },
  {
    "clickRate": "1%",
    "emailId": "1000006",
    "emailName": "The Impact of AI on Web Development",
    "openRate": "48.4%",
    "sends": "2,704",
    "sequenceId": "300001",
    "unsubscribers": "64"
  },
  {
    "clickRate": "0.5%",
    "emailId": "1000007",
    "emailName": "Essential Tech Gadgets for 2024",
    "openRate": "48.9%",
    "sends": "2,629",
    "sequenceId": "300001",
    "unsubscribers": "69"
  },
  {
    "clickRate": "1.1%",
    "emailId": "1000008",
    "emailName": "Top Cloud Solutions for Startups",
    "openRate": "50%",
    "sends": "2,552",
    "sequenceId": "300001",
    "unsubscribers": "90"
  }
]

I've checked the JSON on https://jsonlint.com/ and the JSON is valid.

When I fill in the Make.com webhook at URL, 'display results in window' will give me this error:

Note: Unnecessary use of -X or --request, POST is already inferred.
  
* Connection #0 to host hook.eu1.make.com left intact
Unexpected token c in JSON at position 17

When I just type some random text in value 1, there is no problem. Do you maybe know how to solve this?

test send json to make - question km forum.kmmacros (5.0 KB)

Using Zapier webhooks - Catch Hook

I ultimately want to send JSON to Make.com, but also created a Zapier webhook.

When creating a webhook you can choose "Catch Hook" or "Catch Raw Hook".

When I choose Catch Hook this appears:

I run the macro.

Display results in window:

afbeelding

After this I press the "Test trigger" button:

This is the result:

Using Zapier webhooks - Catch Raw Hook


Run macro.
Result:
afbeelding
Press the test trigger button:

Result:



Do you know why Catch Hook does not work?

But more importantly for me and others who want to send JSON to Make.com;

Do you know how to send JSON from a macro without Unexpected token c in JSON at position 17 error to Make.com?

Could it be that the solution is to create a Plug In Action that is compatible with Make.com? (A customized Plug In Action based on the Send Data to Zapier Webhook Plug In Action?) If so, who can create this Plug In Action?

I don't know the answer to your question, but the only benefit a "plug in action" has over normal macros is that it has a nicer way of specifying parameters. Other than that, there's no real difference, so whatever problem you have, it's not because it needs to be a plugin action.

Thanks for your answer DanThomas.

I'm also interested in answers how sending the JSON to a Make.com webhook can be done without a plug in action.

This:

image

may be related or not, but it is definitely concerning. The text is being processed by Keyboard Maestro, which means % means something and you have those characters all through it unencoded (doubled).

So you will want to fix that (either turn off processing, or adjust your text appropriately).

I don't know how you got to this part:

image

But that is what the problem is. The JSON at that part is incorrect, since it is:

{"value1" : "[{"c…

The " before the c (the c being character 17 that it is complaining about), is not masked and so ends the JSON string.

As to fixed that, I don't know - the JSON has to be encoded as a JSON string I'd guess. Somewhere.

Yes, the plug in action adds "value1".

Because of this I created another ChatGPT prompt and it seems that this works, because this is not added before the original JSON anymore when I just use execute shell script action, instead of using a plug in action.

It seems that this is the solution:

#!/bin/bash

JSON_PAYLOAD=$(osascript -e 'tell application "Keyboard Maestro Engine" to getvariable "jsoncksequence"')

WEBHOOK_URL="https://hook.eu1.make.com/ffoxs6carni3zqh6b8m8ei2tluf3ymof"

curl -X POST "$WEBHOOK_URL" \
  -H "Content-Type: application/json" \
  -d "$JSON_PAYLOAD"