Create sample event using REST API by passing JSON

Vinay Noel
Tera Contributor

Hi Community,

 

We are in need to mimic creation of event from an external application as the connection is not setup to our SN instance from the external application yet.

 

The requirement is to test the Push connector listener script after making some script changes.

We are planning to pass the input event attributes to SN instance as JSON format using REST.

 

Please suggest some ways of passing the JSON input attributes to SN and eventually get the event created after the listener script work its process on the input.

 

sample JSON would look like this -

{
   "source":"SCOM",
   "event_class":"SCOM 2007 on scom.server.com",
   "resource":"C:",
   "node":"name.of.node.com",
   "metric_name":"Percentage Logical Disk Free Space",
   "type":"Disk space",
   "severity":"4",
   "description":"The disk C: on computer V-W2K8-dfg.dfg.com is running out of disk space. The value that exceeded the threshold is 41% free space.",
   "additional_info": '{"scom-severity":"Medium","metric-value":"38","os_type":"Windows.Server.2008"}'
  } 

 

Thanks in Advance

7 REPLIES 7

maroon_byte
Mega Sage

That would depend on the API capabilities of your external application. Based on your sample, if your external application is SCOM, then SCOM has REST API capabilities using Powershell scripting.

Another option is if SCOM can put the events in a SQL table. You can use the JDBC data source to pull the events regularly but this option can be tricky to manage because you don't want to pull all events every time and you will also have to clean up the SCOM table to avoid having too many records.

 

Regards,

Sharad

 

Hi @maroon_byte ,

The json i provided was just a sample and does not depict our original input json. 

Thr external application is Spectrum and the connection is not yet setup to send events from Spectrum to SN instance. 

Hence we wanted to mimic the inbound event attributes towards SN instance.

To mimic, try using REST API Explorer to create an event in your non-prod instance. It would give you a sample script as well.

 

https://www.servicenow.com/community/itom-forum/ca-spectrum-connector-definition/m-p/999782/page/2

Hi @maroon_byte ,

 

We tried using Rest API explorer with a POST action on em_event table. After passing the JSON, we are seeing a record getting created in em_event table. But it is in state error and the spectrum connector script does not seem to be acting on the input JSON being sent through the REST API explorer. (The additional info field of the event is being customized and built from the push connector script.) Hence the created event is having an empty additional info.