Much of what I will be doing with the imp is pulling sensor data, processing it using third party REST services, then sending the results back down to the imp for display on an LCD. I have looked for examples on how to hit REST services with Squirrel and can’t seem to find anything. The examples on the Wiki are great but don’t have any REST stuff. I see that there is a Soft Imp node that suggests POST/GET but I’m unclear on how I might parameterize the URL. Can someone help me out please?
The REST stuff is on the server end, not the squirrel end; you use a IO block in the planner to provide the HTTP to event conversion.
I’ve got the HTTP IN working well, but can’t seem to get a node to connect to the HTTP POST node in the planner. I keep getting “This impee has no sync nodes you can connect” but am not entirely sure how to establish/build a sync node. Any help?
Something like this…
local httpPost = OutputPort("Post", "string"); imp.configure("My Impee", [], [ httpPost ]); httpPost.set("Hello, web!");
Rob
Fen Consultants, UK
We should totally find and fix all the places where it still says “sync” when it means “sink”.
Peter
It referred to inputs and output when I looked this morning…
Thank you for your help, Rob, but things still aren’t working for me. I can’t seem to figure out how to use the HTTP Post node. Any pointers?
To give more detail, I create a node but can’t actually get it to noodle to the HTTP Post node without the error. Any thoughts?
I plan to write HTTP In and HTTP Post example scripts at some point over the weekend, including use of the Planner to configure them, so if you haven’t solved it by then hopefully those will help.
Thanks Rob! That will be great!
There’s an example online now. It uses the Hannah temperature sensor, but could easily be modified to log something else if you don’t have a Hannah.
Can you please post the URL for the example?
All the examples are on the development wiki: http://devwiki.electricimp.com/doku.php?id=templog.
Enjoy!
Great example. Thanks for the work you put in to that. I have a clarifying question to help me completely grok the example. If I understand correctly you configure the HTTP POST vimp with the base URL for the web-service. The information sent from the imp will be concatenated on to the base URL that will then be sent to the server. So if I’m watching from the server I should see something like this coming in every 5 seconds -
No, that’s not how it works right now. The URL is a fully defined path to a page that can accept a POST connection. Currently only one value is transfered, in the “value” field. Of course this could be anything - including a combination of several parameters in some format decided by you.