Hello everyone,
I have developed a JavaScript script that retrieves all events associated with a user in an organization.
Currently, my company has two organizations. One of them utilizes Atlassian Guard, while the other does not.
When I run this script in the organization with Atlassian Guard, I successfully obtain all the events related to the user.
However, when I execute the same script in the organization without Atlassian Guard, I encounter the following error message: “error:Payment Required”.
Why does this error message appear in the second organization but not in the first?
Is this error related to the absence of Atlassian Guard in the second organization?
This is the scritpt:
const axios = require(“axios”);
const orgId = “xxxxxxxxx”;
const apiKey = “yyyyy”;
const userId = “54ds456sd564dsf546fsd”;
const url = https://api.atlassian.com/admin/v1/orgs/${orgId}/events
;
const fetchEvents = async () => {
try {
const response = await axios.get(url, {
params: {
q: userId, // Parámetro de consultano
},
headers: {
Authorization: Bearer ${apiKey}
, // Autenticación Bearer
Accept: “application/json”,
},
});
const events = response.data.data;
events.forEach(event => {
console.log(ID del Evento: ${event.id}
);
const attributes = event.attributes;
console.log("Attributes:");
console.log(` Time: ${attributes.time}`);
console.log(` Action: ${attributes.action}`);
// Mostrar el mensaje del evento
const message = event.message;
console.log("Message:");
console.log(` Content: ${message?.content}`);
console.log("-----------------------------");
});
} catch (error) {
console.error(“Error al obtener eventos:”, error.message);
}
};
// Ejecutar la función
fetchEvents();
Thank you!