Hello everyone!
I have two questions related to how I can query or send data from NoteHub to my web app.
The first is: when I configure a route to the server where my app is running, what code do I need to have to receive that JSON? (My server is a Raspberry Pi running a web app with nginx.) What method does NoteHub use to send that JSON? Is it a POST?
The second is: I ran a test with Notehub Py, just the example code that allows me to read general information about a device. But I can’t find much documentation on how I can query specific notes, such as sensors.qo.
Thanks in advance.
Hi @Juan_Cossio,
When you are routing your data from Notehub to your web app / server, the simplest way to handle incoming data is by using a web server (for example, Flask in Python). Your Notefiles are sent by Notehub as an HTTP POST request. We have a guide in the docs for how to use webhook.site to quickly and easily see the incoming data / Notefiles. You will need your Raspberry Pi to expose a public endpoint to the internet, to receive these requests.
The notehub-py library is used to manipulate the Notehub API, which allows you to programmatically access / manage devices and fleets on Notehub, rather than querying specific notes. Notehub’s intended purpose isn’t to store data for consumption by your application, rather to forward data on to your server / database as it is generated (like the routes above).
Thanks,
Alex
Hi @abucknall, thanks for your response.
I tested it with webhook.site and it works, but I still can’t get any data to my Flask server on the Raspberry, so I have a couple of questions. To which port does the Notehub send the JSON? I have a router with a SIM card with a public IP, and I created port forwarding rules to redirect everything arriving on certain ports to the Raspberry IP.
If I create an HTTP header of this type:
can I tell the route to send the POST to that specific port?
In the URL field, I’m entering the public IP of my SIM card.
Thanks.
Can you see the route event on Notehub? It might give you a better idea of what’s going on. There will be an HTTP status code that will tell you if your request is reaching the raspberry pi.
You shouldn’t need to specify which port you want the route to use, just that you have that port exposed on your router via port forwarding.
Have you been able to verify that you can reach your raspberry pi via your public IP?
Thanks,
Alex
This is what the event shows:
.
I can see the Raspberry Pi from the public IP. The web application already has a domain and SSL certificates.
Apparently it’s an nginx configuration problem, I’ll keep checking, thanks.
1 Like