[SOLVED] Data is empty on hook-response

I just started getting into webhooks on my Photon the other day (very nice feature, I hope you guys will keep improving it) and ran into some walls. I’m not sure if they’re mine, or problems with webhooks, or a combination.

I have a small endpoint (written in C#) that accepts POST requests (it just takes a string and then I do what I want from there). When I’m running in localhost mode in Visual Studio, and I create a webhook to post to that URL,I get a hook-response on my dashboard, but the data field is always empty.
When I upload that same service to my server and point a webhook at it, I get no response at all.

What exactly is my webhook sending if simply have a Spark.publish("Test, "test")?

Also, what does the Photon expect in return?

Thanks for your time.

SOLVED!: It was the dumbest mistake I think I’ve ever made. I forgot to put http:// in front of my domain.

Thanks to @peekay123 for his suggestions and @kennethlimcp for directing me to requestb.in. Seems like a nice resource, I’ll keep it in mind for the future.

1 Like

@Ellis, webhooks are fired by a Spark.publish() and the Photon receives a response via a Spark.subscribe(). Have you tried the documented example? You may want to post your webhook as well so we can see what may be going on. :smile:

@peekay123 Thanks for your response.

My webhook is as simple as it can get:

"event": "Test",
"url": "(insert website name here)/api/particle",
"deviceid": "",
"mydevices": "true",
"requestType": "POST",
"headers": "application/json; charset=utf-8",
"json": { "test": "{{SPARK_EVENT_NAME}}" }

I’m using the CLI command: particle webhook create myapi.json.

As I said, when I use this with localhost, I get an empty event on my dashboard.
Sorry for my poor choice of words, I don’t really need to get data back to my Photon as much as I need to see it in my dashboard.

Is this appended to the end of the url you are trying to use?

Can you try replacing the url with one from http://requestb.in and see the server response

Er…Sorry…I’m not quite sure what you mean.

(I may be off here): As far as I know, /api/particle is static, and is not appended when a request is sent.

static? basically you should use the url you want to hit. There’s nothing like /api/particle needed behind or added by the server etc.

See an example here: http://docs.particle.io/photon/webhooks/#particle-webhook-create

@Ellis, when you say “localhost” I assume you are running the targeted server locally? Or do you mean the local Particle Cloud server? Webhooks run in the Cloud and when fired will send a request to the targeted server. If your localhost server is not published publicly then the webhook will not reach your intended target.

1 Like

@kennethlimcp That is the URL I want, for sure. That is the destination for my own API. I have several api’s on my site, so I just named this one particle. The URL targets an MVC controller. Sorry for the confusion.

@peekay123 Sorry for being unclear. Yes, that is the server targeted locally. The funny thing is, it did reach my local server, and pushed an event to dashboard.

@Ellis, on your local server you should be able to see if the request was correctly received and how your server responded, yes?

@peekay123 That’s just it, my local server is working fine. I’ve sent numerous test requests to it using a nice tool called SoapUI, and they all worked. However, when I set up the webhook for the URL, it doesn’t work.

@Ellis, as @peekay123 mentioned,

if your server is local and cannot be reached by the internet, Webhooks will not be able to do it as well. It’s like your TV at home should not be controlled by someone on the other end of the globe when it is powered off :wink: