Is anyone able to provide the body of trigger action of a json POST please? I can't find any real life examples.
For Trap based alerts we use a powershell script that uses json to create service now incidents. I can share that if thats what you are after.
Thanks! The more information and examples the better I say
What application/service is receiving the Json post? The content you need changes based on what consumes it.
Hi! Thanks for the reply. It is going to OpsGenie.
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -Command "D:\SolarWinds\Scripts\SNOW\PROD\SNOWAPI_DPA.ps1 '${N=OLM.AlertingMacros;M=OLMAlertMessage.VbData5}' '${N=OLM.AlertingMacros;M=OLMAlertMessage.VbData4} on ${N=OLM.AlertingMacros;M=OLMAlertMessage.VbData3}' '${N=OLM.AlertingMacros;M=OLMAlertMessage.VbData4} on ${N=OLM.AlertingMacros;M=OLMAlertMessage.VbData3} at ${N=Alerting;M=AlertTriggerTime;F=DateTime}\n\n${N=OLM.AlertingMacros;M=OLMAlertMessage.VbData12}${N=OLM.AlertingMacros;M=OLMAlertMessage.VbData14}\n\nView full device details here: ${N=SwisEntity;M=DetailsUrl}.\nView full alert details here: ${N=Alerting;M=AlertDetailsUrl}\nClick here to acknowledge the alert: ${N=Alerting;M=AcknowledgeUrl}\n\nThis message was brought to you by the alert named: ${N=Alerting;M=AlertName}\nThe node is monitored by the polling engine ${N=SwisEntity;M=Engine.ServerName}' '' '' '' '' ''"
[CmdletBinding()]Param( [Parameter(Mandatory=$False)] [string]$inCI, [Parameter(Mandatory=$False)] [string]$inshortDescript, [Parameter(Mandatory=$False)] [string]$inlongDescript, [Parameter(Mandatory=$False)] [string]$inservice, [Parameter(Mandatory=$False)] [string]$alertID, [Parameter(Mandatory=$False)] [string]$incategory, [Parameter(Mandatory=$False)] [string]$insubcategory, [Parameter(Mandatory=$False)] [string]$SolarWindsCustom1 )#remove FQDN from server name$inModCI = $InCI.split('.')[0]#Log Output$VerbosePreference = "continue"Start-Transcript -Append \SolarWinds\Scripts\SNOW\PROD\DPA.txt# Eg. User name="admin", Password="admin" for this code sample.$user = "USERNAME"$pass = "`"PASSWORD"# Build auth header$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user, $pass)))# Set proper headers$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"$headers.Add('Authorization',('Basic {0}' -f $base64AuthInfo))$headers.Add('Accept','application/json')$headers.Add('Content-Type','application/json')# Specify endpoint uri$uri = "https://SNOW.service-now.com/api/now/table/incident"#$uri = "https://SNOW.service-now.com/api/now/table/incident"# Specify HTTP method$method = "post"# Specify request body$body = "{ `"state`": 1, `"active`": `"true`", `"description`": `"$inlongDescript`", `"cmdb_ci`": `"$inModCI`", `"assignment_group`": `"Operations`", `"category`": `"Database`", `"subcategory`": `"MS SQL Server`", `"contact_type`": `"Monitoring Tool`", `"business_service`": `"Databases`", `"u_contact_number_1`": `"99999999999`", `"state`": 1, `"short_description`": `"$inshortDescript`", `"urgency`": 3, `"location`": `"SITE1`", `"impact`": 3}"[Net.ServicePointManager]::SecurityProtocol = "tls12"# Send HTTP request$response = Invoke-RestMethod -Headers $headers -Method $method -Uri $uri -Body $body# Print response$response.RawContent# End LogStop-Transcript