So this next post is about creating a custom email notification template with a body that contains an XML structure!!! Why would any one want to do this you may ask?

I am working on auto generating tickets in our incident management system, unfortunately due to time and budget constraints the INC system does not support ingestion via REST. Fortunately for me the solution can ingest emails with a specific XML structure in the body and generate the tickets.

So for vRops to use this email method I needed to get it to send an email body with a specific XML structure, after poking around on Dr google and not finding anything to my needs I started playing around and managed figure it out.

(Side note: Here is a great little post at the vmware community forums explaining the suite-api email notification section)

Now I wont provide the full script I built to automate this task end to end, instead I will give an example using the Advanced Rest Client from Google Chrome to create the new email template.

You will need to set the Content-Type header to application/xml and don’t forget the authorization / BASIC header too!! another very important thing is create the email template in plain text!! otherwise it wont work… you do this by setting the html parameter to false.

So to create an XML structure within the XML POST to the Suite-API the data must go within <![CDATA[]]>

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ops:email-template html="false" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ops="http://webservice.vmware.com/vRealizeOpsMgr/1.0/">
    <ops:name>NEWXMLPLAIN</ops:name>
    <ops:template>$Subject=vRops Incident Request
<![CDATA[
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AutoIncident>
	<AlertStatus>SHITCANNED</AlertStatus>
	<AlertID>{{AlertId}}</AlertID>
	<AlertImpact>{{AlertImpact}}</AlertImpact>
	<AlertType>{{AlertType}}</AlertType>
	<AlertSubType>{{AlertSubType}}</AlertSubType>
	<State>{{AlertCriticality}}</State>
	<ResourceKind>{{AffectedResourceKind}}</ResourceKind>
	<ResourceName>{{AffectedResourceName}}</ResourceName>
	<ResourceHealthState>{{ResourceHealthState}}</ResourceHealthState>
	<ResourceRiskState>{{ResourceRiskState}}</ResourceRiskState>
	<Timestamp>{{AlertGenerateTime}}</Timestamp>
	<AlertName>{{AlertDefinitionName}}</AlertName>
	<AlertDescription>{{AlertDefinitionDesc}}</AlertDescription>
	<AlertRecommendations>{{AlertRecommendation}}</AlertRecommendations>
	<AlertLink>{{AlertSummaryLink}}</AlertLink>
</AutoIncident>]]>
  </ops:template>
</ops:email-template>

Once the email template was generated I fired off a GET at https://vrops.vMan.ch/suite-api/api/notifications/email/templates and got the following output! (you coudld also use the Email template manager fling for vRops to check it)

Now that I confirmed my new email template had been created I used the fling “VREALIZE OPERATIONS EMAIL TEMPLATE MANAGER” to set up an alert for my new template.

Then I waited a few minutes for an alert to fire off and got this as the result, sweet all working as required.

Hope this was helpful.

vMan