Hello All,
I'm trying to setup the scripts for a new media type for HaloPSA: Halo API Documentation (halopsa.com), With postman the auth works buy using:
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
myHeaders.append("Accept", "application/json");
var urlencoded = new URLSearchParams();
urlencoded.append("grant_type", "client_credentials");
urlencoded.append("client_id", "XXX");
urlencoded.append("client_secret", "XXX");
urlencoded.append("scope", "all");
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: urlencoded,
redirect: 'follow'
};
fetch("https://us-trial.halopsa.com/token?tenant=XXX", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Then I need to get back the access token in the returned JSON {..."access_token":"XXXX"...} and use in as the Bearer token.
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer XXXX");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify([
{
"team": "Monitoring",
"summary": "This is an example summary",
"details": "This is an example details message."
}
]);
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://XXX.halopsa.com/api/tickets/40", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Can anyone help me get this into a working script in Zabbix Media Types?
Thanks,
Jason
I'm trying to setup the scripts for a new media type for HaloPSA: Halo API Documentation (halopsa.com), With postman the auth works buy using:
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
myHeaders.append("Accept", "application/json");
var urlencoded = new URLSearchParams();
urlencoded.append("grant_type", "client_credentials");
urlencoded.append("client_id", "XXX");
urlencoded.append("client_secret", "XXX");
urlencoded.append("scope", "all");
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: urlencoded,
redirect: 'follow'
};
fetch("https://us-trial.halopsa.com/token?tenant=XXX", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Then I need to get back the access token in the returned JSON {..."access_token":"XXXX"...} and use in as the Bearer token.
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer XXXX");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify([
{
"team": "Monitoring",
"summary": "This is an example summary",
"details": "This is an example details message."
}
]);
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://XXX.halopsa.com/api/tickets/40", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Can anyone help me get this into a working script in Zabbix Media Types?
Thanks,
Jason
Comment