I'm trying to use the grafana API to pause and unpause grafana alerts via a mobile app in React-Native and Expo. following the documentation, with postman, the states are changed correctly, but when I make the app calls I can unpause the alerts but I can't pause them. My grafana workspace is in AWS Managed Grafana
This is my function to change state
const changeAlertsStatus = (item) => {
var state = {
paused: item.state === "paused" ? false : true,
};
console.log(state);
const URL = `${myURL}/api/alerts/${item.id}/pause`;
try {
fetch(URL, {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: SynergyGrafanaApiKey,
},
body: state,
})
.then((response) => response.json())
.then((json) => {
console.log(json);
getAlertsList();
});
} catch (error) {
console.log(error.message);
}
};
This is the console logs when passing "paused"=true
to pause the alert and "paused"=false
to unpause the paused alert (Did it through grafana console)
LOG {"paused": true}
LOG {"alertId": 20, "message": "Alert is already un-paused", "state": "un-paused"}
LOG {"paused": true}
LOG {"alertId": 6, "message": "Alert is already un-paused", "state": "un-paused"}
LOG {"paused": false}
LOG {"alertId": 20, "message": "Alert un-paused", "state": "unknown"}
This is how the app is looking
I would like to understand why, if the alert is paused, the status changes without difficulty, but when I try to pause it, it doesn't allow me and returns that message in the second photo. The call is being made, but for some reason it doesn't change it.
Any other question feel free to ask. I would like to solve this problems. Thanks in advance