Tips for webhook debugging?

I’m currently trying to get my Photon to log data to an InfluxDB (version 0.9) instance. To log a value to the server, I need to POST to a particular URL with a body like “temp,loc=inside value=79.880005”. It isn’t working, and I’m having a hard time debugging the problem.

It is not obvious from the webhook documentation how to POST data that isn’t JSON or form-encoded. Is this possible? Is there a way for me to dump the HTTP request that the Particle Cloud makes to the server when the webhook fires? Any tips for debugging a webhook that isn’t making the request you expect?

Thanks!

If it's not JSON or FORM encoded... then it's likely a QUERY. Check out this example:

...dump the HTTP request that the Particle Cloud makes?

Not currently

Monitor responses:
http://docs.particle.io/photon/webhooks/#handling-web-responses

10 consecutive errors will disable your webhook:
http://docs.particle.io/photon/webhooks/#errors

Hi @seibert,

Good question! If you watch your event feed, you’ll see exactly what comes back from your webhook, try

particle subscribe mine

using the CLI. You can also see what the hook is sending by using a site like http://requestb.in/ It’ll let you generate a url that you can give to your webhook, and then requestb.in will show you exactly what was sent.

I hope that helps! :slight_smile:

Thanks,
David

I have spent hours on this with limited success. requestb.in gives good information and I can verify my server side, but I cannot see enough to know why the request fails from CLI ‘particle publish eventformyapi data’ even though ‘particle publish eventforrequestb data’ seems to work.
I wonder if this is a CORS, SSL, or Remote Database Access Hosts issue with my database. Perhaps if I had the i/p address of the server that forwards the webhook I could add it to my database and it would not fail. Is there any way to see the response sent to your server from mine. This is too hard to troubleshoot blind and ‘particle subscribe mine’ does not help.
Any thoughts are appreciated.

I will attach three screen shots (postman, requestb.in and dashboard). Postman, requestb.in, and my own rest server testing indicate that all is correct. Sorry in advance if I don not thread these together correctly. Notice in them that the requestb.in sure seems to shows that the HTTP POST request from the webhook server is sending the proper content headers and well formated json in the body. However, there is something that my server does not like about it as it responds with an error. One of the things that is confusing to me is the difference between what requestb.in says was sent and what dashboard says was sent.
{“event”:“coughIn”,“data”:“test3sb”,“published_at”:“2015-10-01T04:32:21.975Z”,“coreid”:“001_5xxxxxxxxc_20xxxxx”,“name”:“name”}
versus
{“data”:“test3sb”,“ttl”:“60”,“published_at”:“2015-10-01T04:32:21.975Z”,“coreid”:“001”,“name”:“coughIn”}
Which is the truth?
Anyway, here is the situation
particle to requestb works
postman to my database works
particle to my database does not.
This would be an easy fix if I was allowed to see what my server said to the webhook server when it passed information (headers and body) in the POST.
It is doing something that I can’t see and that requestb doesn’t reveal.
Please let me know how I can view the XHR traffic when the webhook server makes the call so I can see the failure response detail. Otherwise, I cannot make this work (I tried an hour of guess and check to no avail).
Sam

Also, here is the code I used to create the webhook through the particle command line interface:
{
"eventName": "coughIn",
"url": "https://myserver.com/REST/resourceabc",
"json":{"name":"name"},
"headers": {"Authorization": "MyServer 6be29834h57ikft4b6ffa29c2:1"},
"requestType": "POST",
"mydevices": true
}

The hook-response/cough/0 data is the response body. So in this case ok. What are you expecting here?

Requestb.in is the truth for what is sent because you received the actual request from our webhook server. If the published event doesn’t match that, that is a bug in our software.

Is there any difference between how you created the webhooks, or how you are triggering them?

  1. I am triggering them from CLI with particle publish coughIn "garbage string for data"
  2. I created them from CLI with particle webhook create coughIn

The example I showed of the dashboard hook-response/cough/0 in the screen shot above was the response when the URL in my webhook create JSON was http://requestb.in. I do not mean to confuse the issue here; this is not working for my URL. I was trying to show the successful path between my webhook–it’s triggering–and requestb.in as opposed to the lack of success when I change the URL from http://requestb.in/sdfjsldhlsh to https://rpt.clarity.com/sdfjsldfj/sdflkjsldjf. Even though I can prove that the header (content-type and authorization) and body (json) are correct by virtue of success results when I test my URL using Postman and my own REST test lab.
This is why I believe that the way the webhook server configures the header or body is subtly different than I expect – requestb.in is able to handle the difference but my server cannot. As soon as I know what my server says it does not like, then I will be able to adjust for it.
Sam

So you don’t get a hook-response event at all?

Also, is rpt.clarity.com the real hostname? The DNS for it does not resolve.

2 Likes

Yeah! You fixed it. Thank you, thank you, thank you. Now I am getting data from a CLI publish event into my database. Next I will do this from a photon, then take it outside with an electron. I see that the format of dashboard has changed. Perhaps you made a modification or it is fixed with the upgrade, but it is working now! excellent.
Sam

1 Like

was getting generic error without any detail. But now it is working.

no that is not the real host name. But now it is working with today reboot or upgrade.

Photon is dutifully logging data to my database every 15 seconds :stuck_out_tongue:

1 Like

awesome! Glad you guys got this working! (Sorry I missed this, was out on vacation last week :slight_smile: )

Thanks,
David

Now it has stopped working. It was working this morning. But now it is not. Dashboard does not give the response from my server. So we are back to where we were a week ago. 6 days ago Bryce (I thought) did something on your end that allowed the webhook to work. Perhaps this was a reboot of the webhook server? Perhaps it was nothing but chance. Now I was trying to get the electron to do the same. Both give a webhook error. But there is no data in the error response. I know that my server sends something if it is contacted with an invalid POST. I think this is on your end. Please help. And Thanks. Sam