aktuell bin ich dabei ein kleines Webtool zu entwickeln zum vereinfachten registrieren von Geräten in unserem Unternehmen.
Dafür versuche ich mithilfe der JSON-RPC Schnittstelle eine anfrage an unseren Configserver zu schicken.
Meine anfrage sieht wie folgt aus (JavaScript):
Code: Alles auswählen
const data = JSON.stringify({
    id: 1,
    jsonrpc: '2.0',
    method: 'host_createOpsiClient',
    params: [
        'apiDummy.<<domain>>',
        null,
        'Beschreibung',
        null,
        '00:11:22:33:44:55',
        '0.0.0.0',
        null,
        null,
        null,
        null,
        null
    ]
});
const req = new XMLHttpRequest();
req.withCredentials = true;
req.addEventListener('readystatechange', function () {
    if (this.readyState === this.DONE) {
        console.log(this.responseText);
    }
});
req.open('POST', 'https://<<configserver>>:4447/rpc?');
req.setRequestHeader('Content-Type', 'application/json');
req.setRequestHeader('Authorization', 'Basic' + btoa("<<username>>:<<password>>"));
req.send(data);Access to XMLHttpRequest at 'https://<<configserver>>:4447/rpc?' from origin 'http://172.16.31.45' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'http://<<configserver>>:4447' that is not equal to the supplied origin.