cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
602
Views
0
Helpful
1
Replies

NodeJS implementation

felten
Level 1
Level 1

Hey,

If anyone is interested, I've made a NodeJS version to work with the API. Here you go

const request = require('request');

process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; // to ignore the error for self-signed certificates

let cisco_axl_config = {

    url: 'https://YOURURL:8443/axl/',

    auth: 'Basic YOURCREDENTIALS',

    version: 'YOURVERSION'

}

function cucm_exec_sql(query, callback) {

    request({

        uri: cisco_axl_config.url,

        method: 'POST',

        headers: {

            Authorization: cisco_axl_config.auth,

            SOAPAction: 'CUCM:DB ver=' + cisco_axl_config.version + ' executeSQLQuery'

        },

        body: '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.cisco.com/AXL/API/' + cisco_axl_config.version + '"><soapenv:Header/><soapenv:Body><ns:executeSQLQuery><sql>' + query + '</sql></ns:executeSQLQuery></soapenv:Body></soapenv:Envelope>',

        callback: (err, data, response) => {

            callback(err, response);

        }

    });

}

1 Reply 1

akshpras
Cisco Employee
Cisco Employee

I've tried the same methodology but I'm getting the error 'CERT_HAS_EXPIRED'.

 

Please find the below code:

 

Url: http://10.10.20.1:8443

 

request.post({
headers: {
'SOAPAction': `CUCM:DB ver=${this.version}`,
// tslint:disable-next-line:object-literal-sort-keys
'Authorization': `Basic ${this.authToken}`,
'Content-Type': 'text/xml; charset=utf-8',
},
url: this.protocol + '://' + this.host + ':' + this.port + '/axl',
// tslint:disable-next-line:object-literal-sort-keys
body: '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.cisco.com/AXL/API/' + '11.5' + '"><soapenv:Header/><soapenv:Body><ns:executeSQLQuery><sql>' + '' + '</sql></ns:executeSQLQuery></soapenv:Body></soapenv:Envelope>',
// tslint:disable-next-line:only-arrow-functions
}, function(error: any, response: any, body: any) {
// tslint:disable-next-line:no-console
console.log('error', error);
console.log('response', response);
console.log('body', body);
});