
Hello,
I've been looking for a way to get the result of the JSON-RPC for a while, without having to interface with PHP. Preferably via AJAX via jQuery for your own web app.
It hapert already when simply calling the 'RpcInfo.GetServerSettings'. Although I get back a 200 status, but the body is 'undefined'.
With the PHP API, I get the right information, so I think something is wrong with the request.
LOGIN DATA and HOST were masked for security reasons!
const md5 = require('md5');
const request = require('request');
const btoa = require('btoa');
var url = 'https://MyHOST:443/json/',
user = 'MyUSER',
pass = 'MyPASS',
uniqueID = md5('My-app' + Date.now());
require('ssl-root-cas').inject();
request.post({
method: 'post',
uri: url,
headers: {
'Authentication': 'Basic ' + btoa(uniqueID + '-' + user + ':' + pass),
'Content-Type': 'application/json'
},
json: true,
body: JSON.stringify({
version: '1.1',
method: 'RpcInfo.GetServerSettings'
}),
rejectUnauthorized: false
}).on('response', function(data) {
console.log(data.statusCode, data.body);
})
Have I forgotten some permissions, or is there a missing parameter in the header for the request?
Authentication seems to work, otherwise I would certainly get no 200er. Or is that technically not possible to get the response via Ajax correctly?
Does anyone have an idea here, or am I wrong here?
I would be glad about a short feedback.
*This post is locked for comments
I have the same question (0)