Just having some trouble getting a webhook to work from my photon. I realize that I can use the integrated webhooks sent from the particle cloud via a particle.publish but I would like to send the webhook directly from my photon because the server that I am sending it to is locally hosted and not exposed to the world wide web… I have been trying to use the http client library with no success. I wanted to turn to the experts since I clearly am not getting this to send through… GO easy on me…
if i paste this URL in my browser and hit go it successfully fires
First, if you want to talk to the servier directly it’s not really called a webhook.
But your actual problem is that your request.hostname is wrong for two reasons
the scheme/protcol denominator (http://) is not part of the host name
an IP address is no name but an address hence it should be supplied via the request.ip field (the HTTPClient library has been improved to deal with that common misconception, but doing it correct in the first place is the better practice)
In addition to what @ScruffR said, your curl example has the data as part of the path but you are putting your data into the body in the httpclient code. The curl example seems to use the GET method but the httpclient code uses a POST method. After you correct the issues @ScruffR pointed out, you may want to look at how you are adding in the data. Do you truly want GET or POST?
I have the same issue. I have an example which will http.get a public url ok. But if I switch to my local network, it fails. I am starting to think there is a bug in httpclient. I’m kind of surprised we’re the first to run into such a simple thing.
Thanks everyone for the help I knew it would just be a silly way I formatted it. I tried moving the path and the body and different combinations last night before I asked but it was the http:// that threw it off… also putting everything in the path with no body was the right way. I tried the request.ip instead but it spit data type errors so I’m not sure how I should have inputted that differently. I also sent it as a get request no matter how much I read on that stuff I still get the post and get functions confused haha.
I also use httpclient to communicate with a local web server. I wrote the server API and I have no problems receiving the data. Post the code and I’m sure we can help.
Are there any examples that you guys are aware of that do the opposite… For example post a web request to the photon and call a function. Kind of like particle.function but all locally ran? I was able to get this working via MQTT fine but I feel like a web request would work better since the device I will be calling it from doesnt directly support mqtt.
oh man that definitely looks like greek to me haha especially with no sample code in the library… I’m too much of a newby to interpret all that… It looks like you could run the particle cloud locally too but it appears what I found was abandoned and depreciated and I couldn’t get it to install with the newer versions of node and npm. Is there anywhere that this concept has been kept up and developed?
It would be possible to trigger the photon to do something using a local network using TCPclient. It wouldn’t be using the http protocol. I do this by sending JSON messages between photons on a local network. Seems simpler than using a webserver.