devakumaraswamy

Authentication for REST calls

Discussion created by devakumaraswamy on Sep 19, 2014
Latest reply on Sep 21, 2014 by devakumaraswamy

We recently installed the PI REST on our server.

 

My goal is to access the data from nodejs and combine with some other data to do some analytics.

 

Here is my current problem.

 

[I am on windows platform].

 

From my browser I can access a resource like dataservers.

 

https://myserver/piwebai/dataservers.

 

notes: I get prompted to enter my windows userid and password, but I can get to the resource.

 

 

 

However when I call from my nodejs code ( I am using request.js as a wrapper around http calls) I get the message

 

{ statusCode: 401,
:"Authorization has been denied for this request."}'

 

I tried passing my userid, password via 

 

https://myuserid:mypassword@myserver/piwebapi/dataservers'

 

and also as 

 

thru the header:

 

 

 

headers: {

 

Authorization: Basic + new Buffer(userid: password).toString("base64")

 

Both fail..

 

I am hoping I am making a stupid novice mistake and you guys can set me straight.

 

 

 

Thanks...

Outcomes