cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 7

Clearing Alerts in Orion.AlertActive

Jump to solution

Hey guys,

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;

            return Convert.ToBoolean(postAlert.Data);

        }

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?

Tags (1)
0 Kudos
1 Solution

No, like this: [ [ 1, 2, 3, 4 ] ]

View solution in original post

10 Replies
Level 19

What results are you seeing? Error from the server? Server returns false? Something else?

0 Kudos

I'm getting a 400 bad request so i'm thinking its something with the body. The body is a serialized array..example "[2704]".

I saw in the documentation for clearing alerts that it accepts an array of integers.

0 Kudos

What does the code for _Post() look like?

0 Kudos

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).

0 Kudos

You might want to adopt OrionSDK/SwisClient.cs at master · solarwinds/OrionSDK · GitHub for talking to SWIS from C# - it has an InvokeAsync method that takes care of serialization for you.

0 Kudos

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.

0 Kudos

So it needs to accept something like?

{

     "alertObjectIds": [1,2,3,4],

}

0 Kudos

No, like this: [ [ 1, 2, 3, 4 ] ]

View solution in original post

Thank you for the help!!! Clearing the alerts now.

0 Kudos

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

0 Kudos