'Using IFTTT web hook with values; values doesn't get through

I am running the following Javascript code:

const httpPost = (title, msg, trigger, key) => {
    const URL = `https://maker.ifttt.com/trigger/${trigger}/with/key/${key}`
    const data = {
        value1: title,
        value2: msg
    }
    fetch(URL, {
        data: data,
        headers: { "Content-Type": "application/json" },
        method: "POST"
    }).then(console.log).catch(console.error)
}

The web hook got triggered. However, the values are not provided.

When I check https://ifttt.com/activity/applet/... I can see it was triggered and the values are empty.

Even when I JSON.stringify() the data the value fields are still empty. What am I doing wrong?

Instead of data I also tried body or payload as options. The results didn't change. Any ideas?



Solution 1:[1]

If you're posting the body encoded in JSON format, you should use a different Maker URL. Instead of what you have try https://maker.ifttt.com/trigger/{event}/json/with/key/{key}. The URL that you're sending to is for form encoded data.

See this Help Center article on IFTTT: https://help.ifttt.com/hc/en-us/articles/4405029291163-Parsing-JSON-body-with-filter-code

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rob