node-xmlrpc
node-xmlrpc copied to clipboard
trying XML RPC client with an https request
Hi, I'd like to use your node xmlrpc module to make requests to a Odoo server http://www.odoo.com/documentation/10.0/api_integration.html
I've tried : const client = xmlrpc.createClient("https://[myOdooServer]/xmlrpc/2/common") client.methodCall('version ', [], function (error, value) { console.log('Method response for 'version': ' + value) })
And I've got the following error : http_client.js:55 throw new Error('Protocol "' + protocol + '" not supported. ' + ^ Error: Protocol "https:" not supported. Expected "http:"
Do I miss something or is this module not adapted for https requests ?
you need to use:
const client = xmlrpc.createSecureClient("https://[myOdooServer]/xmlrpc/2/common")
(I also found that confusing)
This one works for me (v15) enterprise:
username='admin'
password = 'admin'
db = 'demo_150_1641216360'
url = 'https://demo3.odoo.com'
const client = xmlrpc.createSecureClient(url+"/xmlrpc/2/common");
client.methodCall('version', [], function (error, value) {
if (error){
console.log('Error when calling a method: '+ error);
return;
}
console.log('Method response for version: ', value);
});
client.methodCall('authenticate', [db, username, password, {}], function (error, uid) {
if (error){
console.log('Error when calling a method: '+ error);
return;
}
console.log('uid:', uid);
});