# Webhook frustration

**URL:** <https://community.particle.io/t/webhook-frustration/16732>\
**Category:** Troubleshooting\
**Created:** [October 20, 2015, 11:53pm UTC](https://community.particle.io/t/webhook-frustration/16732 "2015-10-20T23:53:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ctmorrison](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ctmorrison/32/7396_2.png) [@ctmorrison](https://community.particle.io/u/ctmorrison)\
**Post date:** [October 20, 2015, 11:53pm UTC](https://community.particle.io/t/webhook-frustration/16732/1 "2015-10-20T23:53:34Z")

</div>

I’ve read the documentation about webhooks about 50 times. I created a very simple webhook and called it by name via Spark.publish(), but for the life of me, I can’t get it to work. Are there any other guides that I might look at for assistance? This is terrible frustrating for an experienced Electric Imp developer who’s trying to take an objective look at Particle.

---

<div class="post-metadata">

**Author:** ![LukeUSMC](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/lukeusmc/32/6519_2.png) [@LukeUSMC](https://community.particle.io/u/LukeUSMC)\
**Post date:** [October 21, 2015, 12:02am UTC](https://community.particle.io/t/webhook-frustration/16732/2 "2015-10-21T00:02:56Z")

</div>

If you post the code you are using it helps others assist you. All we know is you are having trouble with a webhook and that’s it.

---

<div class="post-metadata">

**Author:** ![ctmorrison](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ctmorrison/32/7396_2.png) [@ctmorrison](https://community.particle.io/u/ctmorrison)\
**Post date:** [October 21, 2015, 12:05am UTC](https://community.particle.io/t/webhook-frustration/16732/3 "2015-10-21T00:05:46Z")

</div>

What’s the best way to post code?

Lemme try this:

```
{
"event": "grovestreams",
"url": "http://grovestreams.com/api/feed?compid=mhgd&api_key= ******** &fred=17.17",
"requestType": "PUT",
"headers": {
      "Host":"grovestreams.com",
      "X-Forwarded-For": "abcde"
 },
"mydevices": true,
"noDefaults": true
}

```

I called it with

```
Spark.publish("grovestreams");

```

Is it required/advisable to have a Spark.subscribe() to accept any response?

---

<div class="post-metadata">

**Author:** ![ctmorrison](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ctmorrison/32/7396_2.png) [@ctmorrison](https://community.particle.io/u/ctmorrison)\
**Post date:** [October 21, 2015, 12:25am UTC](https://community.particle.io/t/webhook-frustration/16732/4 "2015-10-21T00:25:57Z")

</div>

Yikes. I need to learn to post earlier in the process, because it somehow clears my mind and I can see what I’m doing wrong. With a plethora of API keys floating around for various reasons, I had copy-pasted the wrong one. I am successfully posting data.

Since I’ve started this, I’m wondering how I best add something like A1=72.3&AI2=45&AI3=77.1&DI1=1&DI2=0 dynamically to my URL. I’m a bit unclear as to how I best pass up to 12 inputs to Grovestreams via the webhook.

Thanks!

---

<div class="post-metadata">

**Author:** ![kennethlimcp](https://avatars.discourse-cdn.com/v4/letter/k/c0e974/32.png) [@kennethlimcp](https://community.particle.io/u/kennethlimcp)\
**Post date:** [October 21, 2015, 12:46am UTC](https://community.particle.io/t/webhook-frustration/16732/5 "2015-10-21T00:46:32Z")

</div>

Not sure how you miss this:  
[https://docs.particle.io/guide/tools-and-features/webhooks/#query](https://docs.particle.io/guide/tools-and-features/webhooks/#query)

---

<div class="post-metadata">

**Author:** ![LukeUSMC](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/lukeusmc/32/6519_2.png) [@LukeUSMC](https://community.particle.io/u/LukeUSMC)\
**Post date:** [October 21, 2015, 2:06am UTC](https://community.particle.io/t/webhook-frustration/16732/6 "2015-10-21T02:06:32Z")

</div>

Put it in a string then publish the string. If they take JAON data I think that’s the best route.

PS: Spark.whatever() is being deprecated. I would switch to Particle.whatever() now to avoid future issues.

---

<div class="post-metadata">

**Author:** ![ctmorrison](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ctmorrison/32/7396_2.png) [@ctmorrison](https://community.particle.io/u/ctmorrison)\
**Post date:** [October 21, 2015, 2:36am UTC](https://community.particle.io/t/webhook-frustration/16732/7 "2015-10-21T02:36:23Z")

</div>

@kennethlimcp, I did see that documentation, but it was/is unclear to me as to how I best pass the data from the Photon to the web hook and reference those values in the context of the query. I’ll do some more testing.

@LukeUSMC, thanks for the advice. I will switch to Particle.whatever(), but had fallen back to the Spark.whatever() in a futile attempt to get it working. WRT the string, I’m trying to decide if I simply want to build a string and pass it or if I should use the query capability. Grovestreams does accept JSON, I believe, so I may look more in that direction.

---

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dave/32/181_2.png) [@Dave](https://community.particle.io/u/Dave)\
**Post date:** [October 21, 2015, 5:29pm UTC](https://community.particle.io/t/webhook-frustration/16732/8 "2015-10-21T17:29:22Z")

</div>

Hi @ctmorrison,

I’m glad you got it working! Sorry about the frustrating experience initially, and also welcome to the forums! We’re happy to rubber duck anytime. 🙂

Thanks,  
David

---

<div class="post-metadata">

**Author:** ![indraastra](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/indraastra/32/7286_2.png) [@indraastra](https://community.particle.io/u/indraastra)\
**Post date:** [October 21, 2015, 5:55pm UTC](https://community.particle.io/t/webhook-frustration/16732/9 "2015-10-21T17:55:33Z")

</div>

> [@ctmorrison](#):
>
> @kennethlimcp, I did see that documentation, but it was/is unclear to me as to how I best pass the data from the Photon to the web hook and reference those values in the context of the query. I'll do some more testing.

You've probably found this already, but you can use this to pass data from the Photon as query parameters:

[https://docs.particle.io/guide/tools-and-features/webhooks/#custom-template-variables](https://docs.particle.io/guide/tools-and-features/webhooks/#custom-template-variables)

Actually, since you mention Grovestreams accepts JSON, you may be able to use that example as-is.

---

<div class="post-metadata">

**Author:** ![ctmorrison](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ctmorrison/32/7396_2.png) [@ctmorrison](https://community.particle.io/u/ctmorrison)\
**Post date:** [October 21, 2015, 5:59pm UTC](https://community.particle.io/t/webhook-frustration/16732/10 "2015-10-21T17:59:17Z")

</div>

Hi @Dave,

I do believe the documentation in the area of webhooks could use a little more detail and examples relative to the data passed via the Particle.publish() call. As I understand it, it’s an optional string. If a user wants to pass structured data to reference in the webhook, then format it as a JSON array. The elements (?) are subsequently referenced in the webhook by enclosing them in double curly brackets (ex. {{input1}} ). I guess I don’t understand how to reference the data parameter if you want it in its entirety. Yes, I may be overlooking what’s obvious to others. However, as a newbie, I see things differently and the community may benefit from the naive perspective.

Thanks – I now feel officially welcome!  
Tom

---

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dave/32/181_2.png) [@Dave](https://community.particle.io/u/Dave)\
**Post date:** [October 23, 2015, 3:09pm UTC](https://community.particle.io/t/webhook-frustration/16732/11 "2015-10-23T15:09:51Z")

</div>

Hi @ctmorrison,

Good question! There are four default values available for templating:

```auto
{
    "event": "{{SPARK_EVENT_NAME}}",
    "data": "{{SPARK_EVENT_VALUE}}",
    "published_at": "{{SPARK_PUBLISHED_AT}}",
    "coreid": "{{SPARK_CORE_ID}}"
}

```

If you wanted to reference the event contents value in its entirety you would use “{{SPARK\_EVENT\_VALUE}}”. More info on that is available here: [https://docs.particle.io/guide/tools-and-features/webhooks/#templates](https://docs.particle.io/guide/tools-and-features/webhooks/#templates)

Feedback is always welcome! I’ll keep trying to improve the docs for webhooks, thanks for posting! 🙂

Thanks,  
David

---

<div class="post-metadata">

**Author:** ![indraastra](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/indraastra/32/7286_2.png) [@indraastra](https://community.particle.io/u/indraastra)\
**Post date:** [October 23, 2015, 6:31pm UTC](https://community.particle.io/t/webhook-frustration/16732/12 "2015-10-23T18:31:53Z")

</div>

Hi Dave,

The guide is very helpful and well-written, but it would be lovely if you could add at least a sentence before that section stating that those are **all** the magic variables we have access to. Since it is a guide but also a reference, bits like that would make it more helpful as the latter. That would also motivate the “custom template variables” section that follows.

Thanks!

---

<div class="post-metadata">

**Author:** ![ctmorrison](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ctmorrison/32/7396_2.png) [@ctmorrison](https://community.particle.io/u/ctmorrison)\
**Post date:** [October 23, 2015, 6:57pm UTC](https://community.particle.io/t/webhook-frustration/16732/13 "2015-10-23T18:57:06Z")

</div>

Hi @Dave,

I agree with @indraastra’s comments about the helpful and well-written nature of the guides. I wasn’t meaning to be critical, other than perhaps constructively critical when I indicated the need for a more complete explanation of the Templating capability. As I now go back through the guide, it seems rather obvious to me how it works. However, I struggled (perhaps I’m just dense) with the concept of how structured data could be passed and where all it could be referenced in the webhook.

As I often tell new hires, they see things differently until they get indoctrinated, at which point in time they have a new context for their perspective. It’s during the initial period that they can help us understand those things that just aren’t intuitive to the newbie.

So far, I’m really liking what I see with Particle!

Thanks,  
Tom

---

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dave/32/181_2.png) [@Dave](https://community.particle.io/u/Dave)\
**Post date:** [October 23, 2015, 7:11pm UTC](https://community.particle.io/t/webhook-frustration/16732/14 "2015-10-23T19:11:24Z")

</div>

Hey all!

Totally agree, it’s easy to forget how hard it was to learn something after you’ve learned it. 🙂 So we try to pay close attention to this kind of feedback. It’s sounding more and more like we should add a reference doc page for webhooks in addition to the guide, and I’ll leave myself a task to add a clarifying sentence there. 🙂

Thanks!  
David

---

<div class="post-metadata">

**Author:** ![ctmorrison](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ctmorrison/32/7396_2.png) [@ctmorrison](https://community.particle.io/u/ctmorrison)\
**Post date:** [October 26, 2015, 5:25pm UTC](https://community.particle.io/t/webhook-frustration/16732/15 "2015-10-26T17:25:02Z")

</div>

So…publishing data is working very well. However, I created another webhook to call a PHP script. The publish is firing and calling the PHP script as expected and I see the hook-response in the Dashboard with the expected JSON data I’ve structured. Unfortunately, I have subscribed to that webhook and specified function is not being called. Thoughts?

Here’s the subscription call:

```
Particle.subscribe("hook-response/testhook",doNothing);

```

Here’s the publish call:

```
Particle.publish("testhook");

```

…and here’s the line from Dashboard:

```
{"data":"{\"fred\":\"martha\"} ","ttl":"60","published_at":"2015-10-26T17:24:57.042Z","coreid":"\u0000]\u001cR\u001c","name":"hook-response/testhook/0"}

```

However, in doNothing() I’m incrementing a global variable that is not getting incremented.

I hope I’m just making a newbie error.

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [October 26, 2015, 5:38pm UTC](https://community.particle.io/t/webhook-frustration/16732/16 "2015-10-26T17:38:10Z")

</div>

@ctmorrison, do you possibly have two webhooks of the same name? Creating a webhook with the same name as one that already exists does NOT overwrite it. Instead, it create a new webhook, same name but with a different ID. @Dave, if anything, THIS is something that should be looked at 😉

---

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dave/32/181_2.png) [@Dave](https://community.particle.io/u/Dave)\
**Post date:** [October 26, 2015, 6:00pm UTC](https://community.particle.io/t/webhook-frustration/16732/17 "2015-10-26T18:00:53Z")

</div>

Totally! I created an issue for this in the CLI to warn if that is happening 🙂

Thanks!  
David

---

<div class="post-metadata">

**Author:** ![ctmorrison](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ctmorrison/32/7396_2.png) [@ctmorrison](https://community.particle.io/u/ctmorrison)\
**Post date:** [October 26, 2015, 6:32pm UTC](https://community.particle.io/t/webhook-frustration/16732/18 "2015-10-26T18:32:31Z")

</div>

No…I created a new webhook and only created it once. I had experienced the multiple webhook thingie when I was trying to get publish work initially (I actually like that “feature”). However, this is a new one and there’s only one.

---

<div class="post-metadata">

**Author:** ![ctmorrison](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ctmorrison/32/7396_2.png) [@ctmorrison](https://community.particle.io/u/ctmorrison)\
**Post date:** [October 26, 2015, 7:24pm UTC](https://community.particle.io/t/webhook-frustration/16732/19 "2015-10-26T19:24:22Z")

</div>

Question – due to coding mistakes on my part, I had lots of errors when I was first trying to get webhook publishing working. Is it possible I need to reset something in my account in order to accept webhook responses?

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [October 26, 2015, 7:31pm UTC](https://community.particle.io/t/webhook-frustration/16732/20 "2015-10-26T19:31:34Z")

</div>

@ctmorrison, nope. With all the stuff I tested with webhooks, I would have broken the servers, not just my account! However, you may want to make your subscribe (using MY\_DEVICES) and publishes (using PRIVATE) private so you don’t accidentally get hit by a public event. 😄

[Next page](https://community.particle.io/t/webhook-frustration/16732.md?page=2)
