Uplink from TTN to my php webhook is a GET = no JSON

I have a Dragino CPL03-LB connecting through a Dragino gateway to TTN. I then forward the Uplink messages to my own php webhook on my website where I intend to store data in a MySQL DB.

The calls to my webhook are being made successfully (i.e. no errors in TTN).

However, the requests are coming through as GETs rather than POSTs. And, of course, there is no JSON data accompanying the request.

After fiddling around with my own script I found this script to test with - TheThingsStack-Integration-Starters/WebHook-to-Tab-PHP/TTS.WebHook.Tab.php at main · descartes/TheThingsStack-Integration-Starters · GitHub

The script is hitting the “die” on line #10.

It seems from what I have read that TTN should be sending the request as a POST rather than a GET!

I did see another post about supplying the complete URL so I made sure I was doing this - mywebsite.com est disponible à l´achat - Sedo.com

Any thoughts?

Thanks,
Rodney

What do the docs say to do?

Well, I have been reading the docs over and over and over so let me reiterate what I understand.

https://www.thethingsindustries.com/docs/integrations/webhooks/creating-webhooks/

I created my php script on my website and tested it using Postman. Sending a POST request I received a 200 back.

image

At this point I am not using a Download API key, Request authorization, or any filters for the event data.

image

And, at this point, I am only sending Uplink messages

image

I provided the path “/gateMessage” so according to the doc above it will get appended “appended to the Base URL”.

Specifically, the doc states…
“The paths are appended to the Base URL . In the example from the images above, the Application Server will perform POST requests on the endpoint https://webhook.site/uplinks for uplinks, https://webhook.site/join-accept for join-accept messages, and https://webhook.site/downlink-ack for downlink acknowledgement messages.”

In my own PHP script I have some temporary code to simply dump the server name, request method, and all of the headers. The request is coming through as a GET.

image

I don’t see anything in the docs about a GET vs a POST. All indications are that TTN will in fact send the request as a POST.

So, I believe I have done exactly what the fore mentioned doc specifies for creating a Webhook, including testing it with Postman.

I have done my due diligence and have read this doc many time. Apparently you believe I have missed something. Any help would be appreciated.

Thank you.

Given the referer header in your post I suspect the original post gets redirected somehow.
For all my integrations I am getting POST requests so the documentation is right.

Nope, there was no evidence you’d looked at the docs and given the paucity of detail in your first post, that was the quick win for the volunteer to type that knows that code you tried works because it was used in the TTN Summer Academy by the author.

Good pile of detail but as @kersing says, it does look like there’s a redirect there - is there an .htaccess file doing any url cleanup or are you running a proxy to provide https or anything else that may change the request or interface between it and TTS?

As you’ve a TTI instance, you can of course use your support plan as well.

Interesting thought. I see what you are saying.

After a little more digging I determined it has something to do with the Apache server where my website is running.

I believe it was looking for / assuming it would find an index.html file but could not. So, it forwarded the request to the existing index.php. I definitely do not completely understand it but at least I know how to get around the issue.

Solution → I changed the “optional path” for Uplink messages from “/gateMessage” to “/gateMessage/index.php”.

Now I am getting a POST request along with the JSON.

image

Thanks kersing!!! Your suggested was a great help in me figuring out what the issue was!

There are many settings both in Apache, in the local .htaccess and PHP where the URL has to be tidied up to explicitly point at the right file - it will have worked it’s way through a list of index.html index.htm and then index.php.

All of the above leave your server open to some potentially messy web crawls, so best to remove anything index, call the script something that suits you and then use that name on the TTS console with the file suffix.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.