@oliverio
Hatte jetzt nochmal dieses Script genommen
const axios = require('axios');
function auth() {
axios.post('https://api.emessage.de/auth/login',{
username: 'USERNAME',
password: 'PASSWORD'
},{
headers: {
'Authorization': 'Basic Og==',
'Content-Type': 'application/json',
}
}).then(function (response) {
if (response.status==200) {
var token = response.data.data.jwt;
sendMessage(token)
}
})
.catch(function (error) {
console.log(error);
});
}
function sendMessage(token) {
axios.post('https://api.emessage.de/rs/eSendMessages',{
"messageText": "Testnachricht",
"recipients": [
{
"serviceName": "eCityruf",
"identifier": "********"
}
]
},{
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + token,
}
})
.catch(function (error) {
console.log(error);
});
}
auth();
und bekomme diese Log
javascript.0 (4430) script.js.Alarmierung_Pager_via_Wago.Pager_ausloesen.Test: {'message':'Request failed with status code 401','name':'AxiosError','config':{'transitional':{'silentJSONParsing':true,'forcedJSONParsing':true,'clarifyTimeoutError':false},'transformRequest':[null],'transformResponse':[null],'timeout':0,'xsrfCookieName':'XSRF-TOKEN','xsrfHeaderName':'X-XSRF-TOKEN','maxContentLength':-1,'maxBodyLength':-1,'env':{},'headers':{'Accept':'application/json, text/plain, */*','Content-Type':'application/json','User-Agent':'axios/0.27.2','Content-Length':93},'method':'post','url':'https://api.emessage.de/rs/eSendMessages','data':'{\'messageText\':\'Testnachricht\',\'recipients\':[{\'serviceName\':\'2wayS\',\'identifier\':\'*****\'}]}'},'code':'ERR_BAD_REQUEST','status':401}
und der Pager bleibt still