AnsweredAssumed Answered

PI Connector for UFL and Nodejs

Question asked by ayu Employee on Aug 15, 2017
Latest reply on Aug 17, 2017 by mtippett

Hi,

 

I am writing a javascript application to get data from a weather station and using the connector to get the data into PI. I'm making the HTTP requests on the server side in nodejs but I run into a

"self signed certificate error" with code DEPTH_ZERO_SELF_SIGNED_CERT. I'm using the request module found here: GitHub - request/request:      Simplified HTTP request client.

 

Here is the code snippet causing issues:

 

const pushToConnector = (url, data) => {

    var HTTPSrequest = require('request');

    HTTPSrequest.post({url: url, data : data, Authorization : "Basic " + new Buffer(username + ":" + password).toString('base64') }, function (error, response, body) {

        if (error) {

            return console.error('Failed:', error);

        }

        console.log('Upload successful: ', body);

    } )

}

 

Thanks.

Outcomes