#204 nhaystack connection

Christian Tremblay Mon 25 Aug 2014

I want to connect to a haystack Jace with Python. What would be the best way to handle the connection to the station ?

Mike Jarmy Tue 26 Aug 2014

There is no Haystack Python library/toolkit that I'm aware of. That would be really cool -- go for it :-).

I would just write a zinc parser first, and then start fetching things with whatever Python http library that you like. If you poke around in the haystack-java toolkit you'll see how authentication works.

Christian Tremblay Tue 26 Aug 2014

Tell me if I'm wrong. I was trying to make get request on the station. Authentification is then asked by the station (I'm getting the login html code as my answer...)

Must I authenticate to the haystack servlet directly or to the Jace ?

I'm not sure I understand why I should check haystack-java for authentification.

Thanks for your help

Mike Jarmy Tue 26 Aug 2014

You have to authenticate directly to the Jace's web server (a.k.a WebService). NHaystack does not have its own authentication scheme.

There is an example of doing Basic Authentication from a client to a Jace in org.projecthaystack.client.HClient -- that's why I was pointing you to it. For other forms of AX authentication you will have to refer to Tridium's documentation.

Christian Tremblay Tue 26 Aug 2014

When you refer to basic Authentication, you mean Authentication Scheme ? (wich can be cookie, basic or Cookie Digest) right ?

So If we are typically using Cookie Digest, I'll have to check for that kind of authentication and probably "mimic" what the login page is doing.

Mike Jarmy Tue 26 Aug 2014

Yes, that's correct.

Christian Tremblay Thu 28 Aug 2014

The hardest part was to figure out how the connection was made with cookie digest.

Actually, it's one of the way to learn Pandas :)

And I didn't have to think about a Zinc parser, @Brian worked hard to make the JSON parser work natively in haystack.

I'll share my work hoping that others will play around.

Login or Signup to reply.