What am I doing wrong with my webhook?

I’ve been running a project for many months using calls to https://www.pushingbox.com/ and then using that site to post a GET request to a php script on my servers. Now, I want to cut out the middle man and use webhooks to get the job done.

Here’s my json for setting up the webhook:

    "event": "venus",
    "url": "http://mysite.com/v2/notify.php",
    "requestType": "GET",
    "json": {
        "id" : "{{SPARK_EVENT_VALUE}}",
        "location" : "{{SPARK_CORE_ID}}"
    "mydevices": true

My webhook call looks like this:

Particle.publish("venus", String(value), 60, PRIVATE);

When I trigger the action on my photon I see this when listening in the terminal:

{"name":"hook-response/venus/0","data":"{\"status\":{\"type\":\"error\",\"value\":\"No JSON value set\"}}","ttl":"60","published_at":"2016-04-28T20:47:51.177Z","coreid":"particle-internal"}

I’ve used hurl.it to make sure the code works on my server. It does. Clearly, there’s something wrong with the way I set up my webhook. What am I doing wrong?

This is what I want the request to look like, ultimately:


Thanks in advance for the help. Just ordered two Electrons today and am excited to try this out on them as well!

Shouldn’t you be doing a POST request to your server if you want to pass the json values?

@stuboo, you need to pass the values to the webhook in JSON format. For example, if I want to pass a value that look like this in my webhook:

	"q": "{{mycity}}",

I need to send the mycity in the publish using "\"mycity\":\"Ottawa,ON\"" (in this case, it is a char string). :wink:

1 Like

Tried changing GET to POST. No luck.

I’m confused. I thought Particle.publish() produced json that could then be passed on to my API. I was trying to use this example from the docs as a guide. In that example, it looks as if the webhook itself passes the json request to the API which logs it.

@stuboo, you are using Particle.publish() to fire a webhook to talk to your API. The webhook will format the API request as you define it. To pass data to the webhook, that data needs to be in JSON format. The id and location json objects in your webhook use system generated values (eg. {{SPARK_CORE_ID}}). Nowhere do you add data as a passed object.

If I understand correctly, you want two objects in your webhook: name and data, where name seems to be the name of your device. To get this you will need your webhook’s json definition to look like:

    "json": {
        "name" : "{{SPARK_CORE_ID}}",
        "data" : "{{data}}"

To pass a value for data to your webhook, you will need the publish to look like:

Particle.publish("venus", values, 60, PRIVATE);

where values is an Arduino type String or C string with format:
"\"data\":\"D\"" where “D” is whatever the value of data is. In your case it seems to be a char.

1 Like

@peekay123 Thanks so much. I ended up using the “query” method in my webhook and it’s working well. Now I just need to wait for a response, because at this point, my script is being called 5-6 times with each request. I’m combing through the code on your RGBPongClock now in hopes that I can get some insight on the best way to do that. If you have some other resources or insight into that process, I’d love to hear it.

Thanks for all the help!

@stuboo, what is the response that it takes 5-6 hook responses!? The RGBPongClock webhook uses a template to parse the return JSON to only a few items. Is parsing something you could do with the response?

@peekay123 The response is very short (a simple SUCCESS) message. Here’s what subscribe looks like in the terminal after single call:


I assumed the webhook simply continued to ping my php script until it got a response - please correct me if I’m wrong.

I’ve also uploaded all the files for the project to github if you’re interested. The readme may provide better insight into what I’m trying to accomplish. I plan to open everything up and write some decent instructions when it’s all said and done.

Sincerest appreciation,