Can I get data back to my device using HTTP?
-
So what you are proposing is to set up a virtual datapoint that you can set to 0 or 1 to start or stop the drive and another numeric datapoint which you will set to control the speed of the drive? That should work. You can poll /rest/v1/point-values/POINT_XID/latest?limit=1 to get the latest point value.
What are you going to be using to read the point value and send it to the drive?
-
Excellent Jared. That worked. I tried it in the browser and I could get the data back from Mango. Now I can code on the remote device to poll this data.
I have a custom built data logger running NETMF and this will poll the data over the GPRS connection.
-
Great. The only issue you may have is authentication, the current Mango authentication is all session cookie based. You will have to make sure your HTTP client can handle cookies. You can find the REST end points for logging in in the Swagger documentation, change your
env.properties
so thatswagger.enabled=true
and navigate to/swagger/index.html
Mango 2.8 will support token based authentication for the REST API.
-
Ah, that might be a bit of a problem. There is no cookie capability as this does not have a proper browser.
I tried it on a browser that was not logged in and sure enough, I got an access denied message.
Is it possible to use some form of API key or other method to do this?
-
Nope, at the moment session cookies are the only supported authentication mechanism. 2.8 will have token authentication.
I'm not familiar with NETMF but even if it doesn't support cookies you should be able to manually read the
Set-Cookie
header when you login and send it back in theCookie
header with each request. -
OK. I'll check out how to do this.
-
Here is a link to some documentation about how authentication works which should be helpful:
https://help.infiniteautomation.com/support/solutions/articles/14000023292-mango-rest-api-authentication -
@v8dave
Does your device support Python by chance or some other scripting language? -
Hi Woody, the unit is programmed with C# using .NET Micro Framework running a custom board with the GHI Electronics G400D module.
-
Hmmm, well the C# path may lead you somewhere. Then again, it could be down a rabbit hole I suppose.
-
I should be able to do this one I figure out how to login from the device using TCP/IP. I have a full implementation of the TCP/IP stack on this device. I can then extract the cookie and use this to send back with the request.
It's just another level of coding I need to add. At present I send HTTP without doing any logging in.