I'm trying to clear alerts in SWQL. My code is as follows:
public static bool Clear(IEnumerable<Alert> alerts)
var ids = alerts.Select(alert => alert.AlertObjectID).ToList();
var body = JsonConvert.SerializeObject(ids);
var postAlert = _Post(body, "Invoke/Orion.AlertActive/ClearAlert");
if (false == postAlert.HasData) return false;
I have a similar method to acknowledge alerts and it works fine with Invoke/Orion.AlertStatus/Acknowledge.
Why is clearing the alerts not working (getting 400 error)? I'm sending in an array of AlertObjectIDs?
Solved! Go to Solution.
I'm getting a 400 bad request so i'm thinking its something with the body. The body is a serialized array..example "".
I saw in the documentation for clearing alerts that it accepts an array of integers.
We use the same _Post method for acknowledging alerts and it works. We just feed in a variable uri to change where to talks to in SWIS.
The _Post method uses the WebRequest class to post data SWIS, then reads the HttpWebResponse.
Our code is very similar to what they have on MSDN: How to: Send Data Using the WebRequest Class
I think we just need to know the format on what SWIS will accept to clear alerts (i thought it was just an array of alertObjectIds).
Oops! I just realized what the problem is. The post body for /Invoke/* is a json list of the arguments. ClearAlert expects one argument: a list of ids. So the post body needs to be a list of a list.
I don't see anything obviously wrong here. Look in the SWIS log on the Orion server to see if it has some error details: C:\ProgramData\SolarWinds\InformationService\v3.0\Orion.InformationService.log
SolarWinds solutions are rooted in our deep connection to our user base in the THWACK® online community. More than 150,000 members are here to solve problems, share technology and best practices, and directly contribute to our product development process.