HOME › Forums › Gateways › Raspberry Pi › REST HowTo?
-
AuthorPosts
-
AnonymousInactiveAugust 17, 2015 at 5:02 amPost count: 6
The examples given in the wiki aren’t as easy to follow at it seems. Can you provide any real examples I can use?
curl http://192.168.*.*:50333/devices -XGET
– returns “Not authenticated”. I’ve tried authentication with Postman (Chrome App) as well and not succeeding. Is the default username admin? I’d like to learn more and use the REST capabilities.
Thanks!
AnonymousInactiveAugust 21, 2015 at 5:26 amPost count: 6Not that I’d consider this progress but looking at config.ini I discovered the default username appears to be RasperrryPi. PwdFlag=False though so when I try to authenticate with RESTClient in Firefox I still get “not authenticated”. Under the [client] section of config.ini I tried to use that password along with RaspberryPi to no avail.
No idea how to authenticate using ‘curl’ or if I can disable authentication. Anybody got some insight?!
AnonymousInactiveAugust 25, 2015 at 6:23 pmPost count: 259Hey,
REST is in development mode, and in this mode the System API’s are not yet fully functioning. As of now you can only access the REST API with a Computer (or other device) in the same network as the Gateway.
So to help you move forward, please ignore the System API’s. I’m a Postman fan myself… so here’s a collection you can use to test/develop the REST API.
https://www.getpostman.com/collections/a7e361d5a8f7f0d82410Please let us know if you find any issues or have any kind of feedback regarding the API. Will appreciate it very much.
Thanks,
AnonymousInactiveMay 4, 2016 at 4:21 pmPost count: 22At the risk of resurrecting a dead thread…
I am attempting to use the REST API on my gateway. The documentation on the authenticate method seems light, but I think I understand that in order to authenticate, you would send a POST message with the hash of the password.
this seems like the appropriate syntax to me, looking at examples of other POST examples in the API docs:
curl http://MyServer:MySocket/system/authenticate -d”Password=MyHashValue” -XPOST
this command connects but yields a Not Authenticated message
{ "Password" : "d13a9c616a3f2772e2aa406d7ecc9470dd2dc605", "action" : "post", "args" : null, "error" : "Not authenticated", "id" : 0, "objs" : [ "system", "authenticate" ], "session_id" : "" }
The log file shows that the session is initiated and the the parameter is getting parsed
ZBPServer[23867]: Incoming connection.
ZBPServer[23867]: http_parser:: POST /system/authenticate/
ZBPServer[23867]: http:: param: Password value:d13a9c616a3f2772e2aa406d7ecc9470dd2dc605but then the session ends
ZBPServer[23867]: Scheduler:: socket removedSo, how to debug this further..
is Password the correct parameter name? the exact same results occur if I change the parameter name to any random stringthe docs say that the password should be the SHA1 hash value. I tried using shasum to create the hash, as well as using the actual hash value in the config.ini file, and just for grins using clear text.
are other parameters expected in addition to password? Not sure why the return says Args:null..
thanks for any pointers. this seems like a simple thing to start with.
JayAnonymousInactiveMay 4, 2016 at 6:39 pmPost count: 259Hi Jay,
The System API’s are not yet completely activated. As of now you can only consume the REST API within the LAN.
So to help you move forward, please skip the System API calls, you will be able to consume other API without authentication.
We have a collection of API’s to help get started and that’s what I would recommend, you can use the Postman REST Client to start testing, here’s the link of collections:
https://www.getpostman.com/collections/a7e361d5a8f7f0d82410Please let us know if you find any issues or have any kind of feedback regarding the API. Will appreciate it very much.
Thanks,
AnonymousInactiveMay 6, 2016 at 2:48 pmPost count: 22Thanks,
so continuing along, I expect the next simplest command would be:
curl http://MyGateway:MyPort/devices -XGET
which returns:
{ "action" : "get", "args" : null, "error" : "Not authenticated", "id" : 0, "objs" : [ "devices" ], "session_id" : "" }
and the log also shows this as connecting and parsing more or less as I would expect:
ZBPServer[1156]: Incoming connection.
ZBPServer[1156]: Scheduler:: socket added
ZBPServer[1156]: http_parser:: GET /devices
but then…
ZBPServer[1156]: Scheduler:: socket removedI tried this both from a LAN device on the same network and on the local host – same result
thanks
JayAnonymousInactiveMay 6, 2016 at 3:12 pmPost count: 22I followed your suggestion and installed PostMan. I installed your collection as well. thanks for that.
I setup my globals with my IP and PORT, then executed the devices sample from your collection.
the result is shown in the attached screenshot but the important part is:
“error”: “Not authenticated”,
both the MacBook running PostMan and the Pi are on the same LAN (192.168.1.x)
additional troubleshooting / debugging suggestions appreciated.
thanks
AnonymousInactiveMay 6, 2016 at 4:44 pmPost count: 259Hi Jay,
For REST API use port 50334
Port 50333 is for the XML API which uses Authentication.Try
GET http://GatewayIP:50334/devicesAnonymousInactiveMay 8, 2016 at 12:34 pmPost count: 22thanks
using port 50334 works fine 🙂jay
AnonymousInactiveMay 8, 2016 at 1:13 pmPost count: 22I expected the Get Devices Capabilities command to provide the methods available for each device. it does not. there’s no significant difference between the result of Get Devices vs Get Devices Capabilities except that the later does not return the MAC.
is there a list somewhere of the methods for each device type? or some other function to call that responds with the available methods per device?
thanks
Jay
AnonymousInactiveMay 8, 2016 at 6:00 pmPost count: 259It looks like the components did not get discovered. This could happen if the zbpserver plugins are not installed. Can you please check if the plugins are installed:
ls /usr/lib/zbp/plugins
If they are not installed, then install them using:
sudo apt-get install zbpserver*
Take a look at this post:
http://forum.smartenit.com/viewtopic.php?f=48&t=1020If the plugins are installed, then could you please email me the logs: /var/log/zbp
Thanks
AnonymousInactiveMay 9, 2016 at 12:40 pmPost count: 22true – the plugins were not installed.
I resolved that, thank you. restarted the server.
I then attempted to rediscover the capabilities of a few devices, but still the results are the same.snippet from log file is below
May 9 12:35:07 raspberrypi ZBPServer[20849]: http_parser:: POST /devices/15237/capabilities/discover
May 9 12:35:08 raspberrypi ZBPServer[20849]: NodeMgmt::post method called for device 15237
May 9 12:35:08 raspberrypi ZBPServer[20849]: NodeMgmt:: Rediscovering device capabilities: id:3b85
May 9 12:35:08 raspberrypi ZBPServer[20849]: Scheduler:: socket removed
May 9 12:35:10 raspberrypi ZBPServer[20849]: Scheduler:: socket removed
May 9 12:35:28 raspberrypi ZBPServer[20849]: Incoming connection.
May 9 12:35:28 raspberrypi ZBPServer[20849]: Scheduler:: socket added
May 9 12:35:28 raspberrypi ZBPServer[20849]: http_parser:: GET /devices/capabilities/
May 9 12:35:28 raspberrypi ZBPServer[20849]: Scheduler:: socket removed
May 9 12:35:52 raspberrypi ZBPServer[20849]: Incoming connection.
May 9 12:35:52 raspberrypi ZBPServer[20849]: Scheduler:: socket added
May 9 12:35:52 raspberrypi ZBPServer[20849]: http_parser:: POST /devices/15851/capabilities/discover
May 9 12:35:52 raspberrypi ZBPServer[20849]: NodeMgmt::post method called for device 15851
May 9 12:35:52 raspberrypi ZBPServer[20849]: NodeMgmt:: Rediscovering device capabilities: id:3deb
May 9 12:35:52 raspberrypi ZBPServer[20849]: Scheduler:: socket removed
May 9 12:36:00 raspberrypi ZBPServer[20849]: Incoming connection.
May 9 12:36:00 raspberrypi ZBPServer[20849]: Scheduler:: socket added
May 9 12:36:00 raspberrypi ZBPServer[20849]: http_parser:: GET /devices/capabilities/
May 9 12:36:00 raspberrypi ZBPServer[20849]: Scheduler:: socket removed
May 9 12:36:25 raspberrypi ZBPServer[20849]: Incoming connection.
May 9 12:36:25 raspberrypi ZBPServer[20849]: Scheduler:: socket added
May 9 12:36:25 raspberrypi ZBPServer[20849]: http_parser:: GET /devices/15851/capabilities
May 9 12:36:25 raspberrypi ZBPServer[20849]: Scheduler:: socket removedAnonymousInactiveMay 9, 2016 at 4:01 pmPost count: 259Glad to hear that.
Feel free to ask any questions you have. Are you working on an App?
AnonymousInactiveMay 9, 2016 at 4:05 pmPost count: 22I still don’t have any device capabilities
[attachment=0:37zu3y9m]Screen Shot 2016-05-09 at 12.04.58 PM.png[/attachment:37zu3y9m]
AnonymousInactiveMay 9, 2016 at 4:11 pmPost count: 22i find these lines at the beginning of the log file when I restart the server. does this provide anything useful?
May 9 12:31:11 raspberrypi ZBPServer[20849]: LoadPostProcessingLst:: Loading Post Processing list.
May 9 12:31:11 raspberrypi ZBPServer[20849]: LoadPostProcessingLst:: File not found!
May 9 12:31:11 raspberrypi ZBPServer[20849]: LoadHistoryRecordsLst:: Loading Post Processing list.
May 9 12:31:11 raspberrypi ZBPServer[20849]: LoadHistoryRecordsLst:: File not found!
May 9 12:31:11 raspberrypi ZBPServer[20849]: LoadModelReference:: File not found!
May 9 12:31:11 raspberrypi ZBPServer[20849]: LoadPluginMappingReference:: File not found! -
AuthorPosts
- You must be logged in to reply to this topic.