Push connector is not receiving events as excepted

Ganeshm1
Tera Guru

Hello Everyone,

 

Hope you are doing good. 

I am trying to configure push connector for events integration. When I am trying this in API Explorer, its not working as expected.

 

Below are my configurations

Created a push connector 

 

Ganeshm1_0-1744168105113.png

 

URL Parameter: https://<Instance_name>/api/sn_em_connector/em/inbound_event?source=TestEvent

Copied the code from ServiceNow docs "integrate with push connector" and modified the source value in the code by following the below link

 

(function process(/*RESTAPIRequest*/ request, body) {
	/*Function that receives a JSON object, adding all its fields to the Additional information object. The field name is a concatenation of the field key and the parent field key if it exists.*/
	function updateAdditionalInfo(event, field,jsonObject,additionalInfo) {
        for (var key in jsonObject) {
            var newKey = key;
            if (field != "") {
                newKey = field + '_' + key;
            }
			// You can do some transformation here and set fields on the event
			//if(key == "MySource")
			//   event.source = jsonObject[key];
            additionalInfo[newKey] = jsonObject[key];
        }
    }
    
    try
	{		
        gs.info("TransformEvents_generic received body:" + body);
		var jsonObject = JSON.parse(body);
        var event = new GlideRecord('em_event');
		event.source = "TestEvent"; //TODO: Need to define
        event.event_class = "GenericJsonClass"; //TODO: Need to define
        event.severity = "5";
		
        var additionalInfo = {};
        updateAdditionalInfo(event, "",jsonObject,additionalInfo);
		/*Iterates over Additional information JSON object and adds all nested objects' fields as fields of the Additional information object*/
        var notDone = true;
        while (notDone) {
            notDone = false;
            for (var key in additionalInfo) {
                if (Object.prototype.toString.call(additionalInfo[key]) == '[object Object]') {
                    notDone = true;
                    updateAdditionalInfo(event, key,additionalInfo[key],additionalInfo);
					additionalInfo[key] = "";
                }
            }
        }
		gs.info("TransformEvents_generic generated additional information:" + JSON.stringify(additionalInfo));
        event.additional_info = JSON.stringify(additionalInfo);
        event.insert();
	}
	catch(er){
		gs.error(er);
		status=500;
		return er;
	}
	return "success";
})(request, body);

 

 

When I am testing in Rest API explorer with below details its not working as expected

 

Ganeshm1_1-1744168274369.png

 

JSON code I add in explorer 

 

 

{
  "source": "TestEvent",
  "node": "Test",
  "type": "Test",
  "message_key": "1234",
  "description": "Description Value",
  "severity": "1"
}

 

 

after execution getting the bad request error as below. 

 

{
  "error": {
    "message": "No Push Connector Listener script found for given header or source ",
    "detail": ""
  },
  "status": "failure"
}

 

 

I know I might be doing something wrong in my configuration. Please help me to fix this issue. Thanks in advance!

Best Regards,
Ganesh

1 ACCEPTED SOLUTION

Ganeshm1
Tera Guru

Hello Everyone,

After configuring the steps mentioned in my question description

Followed the steps which are mentioned in below article

https://www.servicenow.com/docs/bundle/yokohama-it-operations-management/page/product/service-operat...

 

then copied the URL from URL parameter for end point, used basic auth and some sample json pay of event.

It was successfully able to create event in Event table. 

View solution in original post

3 REPLIES 3

Jeffreys Quinti
Tera Contributor

Hi Ganesh,

 

In your push connector configuration, try changing Header name value to "user-agent" and Header value to "TestEvent"

 

This should fix your problem.

@Jeffreys Quinti : I have modified the changes you suggested

 

Ganeshm1_0-1744263803705.png

In api explorer added the below information

 

Ganeshm1_1-1744263865886.png

JSON body as below 

{
"source": "TestEvent",
"node": "Test",
"type": "Test",
"message_key": "1234",
"description": "Description Value",
"severity": "1"
}

 

but still getting the same error. Could you please help me here what else I should try.

Thanks for your reply. 

Ganeshm1
Tera Guru

Hello Everyone,

After configuring the steps mentioned in my question description

Followed the steps which are mentioned in below article

https://www.servicenow.com/docs/bundle/yokohama-it-operations-management/page/product/service-operat...

 

then copied the URL from URL parameter for end point, used basic auth and some sample json pay of event.

It was successfully able to create event in Event table.