Event fields not populating when executing api post

brentvardy
Kilo Expert

Hi,   I'm very new to the community and to Service Now Event Management.   I'm building a Ruby script that will post events to my Service Now Event Management instance. So far I am successfully, at least it appears so, events.   The Events show up in my instance however none of the fields that I am passing through as the POST data are not getting populated in to the event.   The JSON response I receive on making the call does not include any errors.  

Here is an example of the event (hardcoded currently) in ruby:

snow_event = {

    record: [

  {

    source: 'dev-monitor',
    ci_type: 'cmdb_ci_apache_web_server',
    resource: 'disk',
    node: 'server01',
    metric_name: 'Free Disk Space',
    type: 'disk_check',
    severity: '2',
    description: 'DISK WARNING - free space: /var 8%'
    }

  ]

}

Once the event is created in Service Now none of these fields are populated.   FYI I am using the httparty GEM to make the REST call.

This is what the event looks like in the Service Now interface:

find_real_file.png

This is an example of the response from the call:

{

    "result": {

    "resolution_state": "New",

    "processing_sn_node": "",

    "description": "",

    "source": "",

    "sys_updated_on": "2017-05-24 09:00:05",

    "type": "",

    "ci_identifier": "",

    "sys_id": "ede3b6e3db36f600f33471910f96192f",

    "sys_updated_by": "!!REMOVED!!",

    "ci_type": "",

    "metric_name": "",

    "processing_notes": "",

    "sys_created_on": "2017-05-24 09:00:05",

    "sys_domain": {

    "link": "https://!!REMOVED!!.service-now.com/api/now/table/sys_user_group/global",

    "value": "global"

  },

    "state": "Ready",

    "message_key": "",

    "sys_created_by": "!!REMOVED!!",

    "time_of_event": "2017-05-24 09:00:05",

    "severity": "",

    "error_msg": "",

    "cmdb_ci": "",

    "resource": "",

    "sys_mod_count": "0",

    "classification": "0",

    "sys_tags": "",

    "bucket": "85",

    "node": "",

    "processed": "",

    "additional_info": "",

    "processing_duration": "",

    "event_class": ""

  }

}

Any help in getting past this would be much appreciated.

1 ACCEPTED SOLUTION

Tony,



Thanks for the Postman example, I've now managed to resolve my problem because of this.   Here is a working example in Ruby using the httparty GEM:



snow_payload = {


    source:   "dev-monitor",
    node:   "server02",
    ci_type:   "cmdb_ci_apache_web_server",
    type:   "Free Disk Space",
    resource:   "/var",
    severity:   "3",
    metric_name:   "disk_check",
    description:   "Disk warning - free space /var 8%"
}



snow_auth = {:username => SNOW_USER, :password => SNOW_PASS}



snow_options = {


    basic_auth: snow_auth,
    verify: false,
    verify_peer: false,
    headers: {


    'Accept' => 'application/json',
    'Content-Type' => 'application/json'
    },
    body: snow_payload.to_json


}



response = HTTParty.post(SNOW_URL, snow_options)


View solution in original post

14 REPLIES 14

chandran
Kilo Contributor

How are you executing the ruby, how are you accessing servicenow instance from your script.


Currently I am just executing the script manually from the command line on a linux server.   The script is accessing service now via the REST api over https.


prabh
Mega Expert

Create a scripted rest API at servicenow end for parsing/stringfy the JSON response.


@prabh can you please elaborate on your suggestion, I'm not sure I understand.   Many Thanks.