Bulk delete Canceled Alerts in vRealize Operations using the REST API and Postman
| 2 minutes
VMware vRealize Suite vRealize Operations Manager REST Postman How-To

Hello again!

Today a customer was working with the vRealize Operations 8.0 REST API in Postman and trying to bulk delete “Canceled Alerts”. The documentation in the API states that you need to request a DELETE against the https://{vra-fqdn}/suite-api/api/alerts/bulk API and you should be OK. Well, not exactly.

I’ll start this post by assuming that you’ve seen the excellent Postman collection on VMware {code}. This will get you up and running quickly and allow you to login and get an authentication token.

Let’s get started. The customer wants to use the https://{vra-fqdn}/suite-api/api/alerts/bulk API to bulk delete. Assuming you’ve already logged in, you will need to create a new Request in Postman with the following details:

If it looks familiar, it should. I basically duplicated an existing request in the Postman collection and tweaked it. The {{bearerToken}} variable is just what I use to store the token from the login request. If you ran this now it will fail and Postman will give you a nice message in return:

{
    "message": "Invalid input format.",
    "moreInformation": [
        {
            "name": "api-uri",
            "value": "/suite-api/api/alerts/bulk"
        }
    ],
    "httpStatusCode": 400,
    "apiErrorCode": 400
}

Looking over the documentation, you’ll note that the request does not need any parameters, but it does require a body of type ns3:alert-query. The ns:3alert-query type is simply a list of optional filters that we can use to find alerts so that vRealize Operations can delete them.

The API docs aren’t exactly clear on what it should look like, only what it can contain. As we only want to filter on “Canceled” alerts, there is an alert status property of type ns3:alert-status that we can include in our body. It’s in this alert status that we’ll specify “CANCELED”.

How does it look if that is all we need? Here’s the JSON to include in the body:

{
	"alert-query": {
		"alertStatus": {
			"alertStatus": "CANCELED"
		}
	}
}

Your request in Postman should look like this:

If you would like me to expand on this a bit more, let me know. Happy to update the post.

About Stellios Williams
Senior Cloud Solutions Architect - Service Providers VMware
This is my personal tech related blog for anything private and public cloud - including homelabs! My postings are my own and don’t necessarily represent VMware’s positions, strategies or opinions. Any technical guidance or advice is given without warranty or consideration for your unique issues or circumstances.
Comments
comments powered by Disqus
Advertisement