<h2>Pushing events to the MID Server using web service API</h2><br/><div style="overflow-x:auto"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta content="text/html; charset=UTF-8" /><meta name="copyright" content="(C) Copyright 2025" /><meta name="DC.rights.owner" content="(C) Copyright 2025" /><meta name="generator" content="DITA-OT" /><meta name="DC.type" content="concept" /><meta name="DC.title" content="Pushing events to the MID Server using web service API" /><meta name="abstract" content="Configure the MID WebService Event Collector to provide a URL method to push event messages to the MID Server." /><meta name="description" content="Configure the MID WebService Event Collector to provide a URL method to push event messages to the MID Server." /><meta name="DC.subject" content="Event Management, push operation, script instructions, event collection to, MID Server, transform, URL to push custom payloads, Script include to transform collected events, Event message headers, Authentication and data security options, Authentication type, Secure Connection, Keystore Certificate Alias, Keystore Password, timezone" /><meta name="keywords" content="Event Management, push operation, script instructions, event collection to, MID Server, transform, URL to push custom payloads, Script include to transform collected events, Event message headers, Authentication and data security options, Authentication type, Secure Connection, Keystore Certificate Alias, Keystore Password, timezone" /><meta name="DC.relation" scheme="URI" content="../task/send-events-via-web-service.html" /><meta name="DC.creator" content="ServiceNow" /><meta name="DC.date.created" content="2023-08-03" /><meta name="DC.date.modified" content="2024-02-01" /><meta name="DC.format" content="XHTML" /><meta name="DC.identifier" content="event-collection-via-MID-using-push" /><link rel="stylesheet" type="text/css" href="../../../CSS/commonltr.css" /><title>Pushing events to the MID Server using web service API</title></head><body id="event-collection-via-MID-using-push"> <h1 class="title topictitle1" id="ariaid-title1">Pushing events to the <span class="ph">MID Server</span> using web service API</h1> <div class="body conbody"><p class="shortdesc">Configure the MID WebService Event Collector to provide a URL method to push event messages to the <span class="ph">MID Server</span>.</p> <div class="section">The MID WebService Event Collector, by default, enables you to connect to an event generator and send event messages through the <span class="ph">MID Server</span>, using a URL in the format: <code class="ph codeph">http://{MID_Server_IP}:{MID_Web_Server_Port}/api/mid/em/jsonv2</code> <p class="p">The JSON v2 format is the same as the format that clients use to send event messages to the instance. This URL provides good performance.</p> For more information, see <a class="xref" href="../task/configure-em-context-extension.html" title="Configure the MID WebService Event Collector Context to provide a URL method to push event messages from an external source to the MID Server.">Configure the MID WebService Event Collector Context</a>.<div class="note"><span class="notetitle">Note:</span> <span class="ph">Event Management</span> accepts events in the timezone of the <span class="ph">MID Server</span> through which the listener has sent the event message. If you require a different timezone, you can configure the script as required, see <a class="xref" href="../task/configure-listener-transform-script.html" title="Integrate with a push connector to connect to an external event source. Push connectors process the collected event messages and transform them to the required event format.">Integrate with push connectors</a>.</div> </div> <div class="section"><h2 class="title sectiontitle">URL to push custom payloads</h2> <p class="p">The <span class="ph">MID Server</span> can also receive a custom payload in JSON, XML, or plain text format. In this case, the <span class="ph">MID Server</span> transforms the event messages using the script include that you provide, and then sends the events to the instance. The URL in this case is:</p> <code class="ph codeph">http://{MID_Server_IP}:{MID_Web_Server_Port}/api/mid/em/inbound_event?Transform={Transform_script_name}</code> For an example of a script include, see the default <code class="ph codeph">TransformEvents_xmlSample</code> script include. <p class="p">For an example of how the MID WebService Event Collector transforms JSON formatted event messages, see <a class="xref" href="../task/event-collection-BMCTrueSight.html" title="The MID WebService Event Collector enables you to collect JSON formatted event messages sent from BMC TrueSight Operations Management (TrueSight), previously known as BMC ProactiveNet Performance Management (BPPM), utilizing event stream notification capabilities.">Event collection from BMC TrueSight and BMC TrueSight_v2</a>.</p> <p class="p">To send events in generic JSON format, you can use the URL in this format:</p> <p class="p"><code class="ph codeph">http://{MID_Server_IP}:{MID_Web_Server_Port}/api/mid/em/inbound_event?Transform=TransformEvents_MidJsonGeneric</code></p> <p class="p">In this case, the <code class="ph codeph">TransformEvents_MidJsonGeneric</code> MID script include that is provided in the base instance transforms the event messages into the event fields. All fields are added as <span class="ph uicontrol">Additional Information</span> fields into the ServiceNow event that is generated.</p> <div class="note"><span class="notetitle">Note:</span> The URL in the format <code class="ph codeph">http://{MID_Server_IP}:{MID_Web_Server_Port}/api/mid/em/{transform_script_name}</code>is also supported.</div> <p class="p">The REST API URL for validating connectivity is: <code class="ph codeph">http://{MID_Server_IP}:{MID_Web_Server_Port}/api/mid/em/ping</code></p> </div> <div class="section"><h2 class="title sectiontitle">Script include to transform collected events</h2> <p class="p">Use the required <span class="ph">MID Server</span> script include to transform (parse) collected event messages and populate them into the mapped event field. The <span class="ph">MID Server</span> script include name is composed of a prefix and suffix. The prefix is the mandatory text <code class="ph codeph">TransformEvents_</code> and the suffix is the transform name on the URL, for example, <code class="ph codeph">http://{MID_Server_IP}:{MID_Web_Server_Port}/api/mid/em/xmlSample</code> <code class="ph codeph"></code>. The composed script name is therefore <code class="ph codeph">TransformEvents_xmlSample</code>.</p> <p class="p">You must supply a script include that receives the event messages in a text variable. The script must have a <code class="ph codeph">transform()</code> function that performs the transformation and prepares the return array of Event objects. When the <span class="ph">Event Management</span> plugin is activated, you are provided with the <code class="ph codeph">TransformEvents_xmlSample</code> sample include script that transforms events from XML format.</p> <div class="note"><span class="notetitle">Note:</span> Event fields that are not identical to fields in the event table are saved in the <span class="ph uicontrol">Additional information</span> field.</div> </div> <div class="section"><h2 class="title sectiontitle">Event message headers</h2> <p class="p">Specify the relevant request header value for the <span class="ph uicontrol">Content-Type</span> field according to the format of the event message.</p> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="event-collection-via-MID-using-push__table_uqf_ldy_dy" class="table" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 1. </span>Request header values for the Content-Type</span></caption><colgroup><col style="width:40.48582995951418%" /><col style="width:59.51417004048584%" /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d544210e259">Message format</th><th class="entry cellrowborder" style="vertical-align:top;" id="d544210e262">Content-Type value</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d544210e259 ">JSON</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d544210e262 ">application/json</td></tr><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d544210e259 ">XML</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d544210e262 ">application/xml</td></tr><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d544210e259 ">text</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d544210e262 ">text/plain</td></tr></tbody></table> </div> </div> <div class="section"><h2 class="title sectiontitle">Authentication and data security options</h2> Options for authentication and data security:<ul class="ul" id="event-collection-via-MID-using-push__ul_pz5_cgt_2x"><li class="li"><span class="ph uicontrol">Authentication type</span>, which can be set to either API Key or Basic.</li><li class="li"><span class="ph uicontrol">Secure Connection</span>, which lets you choose whether incoming and outgoing data is secured when transmitted. If you choose the advanced secured option, it requires that you obtain a certificate from a well-known certificate authority, and then provide the <span class="ph uicontrol">Keystore Certificate Alias</span> and the <span class="ph uicontrol">Keystore Password</span>.</li><li class="li"><span class="ph uicontrol">Use MID Unified Keystore</span>, which provides encryption protection and enables you to install a custom certificate in the <span class="ph">MID Server</span> unified keystore. For details, see <a class="xref" href="../product/mid-server/concept/mid-unified-keystore.html" target="_blank" rel="noopener noreferrer">Install custom certificates in the MID Server unified key store</a>.</li><li class="li">Users must supply a script that receives the JSON, XML, or text formatted event messages in a text variable. The script must have a transform() function that performs the transformation and prepares the return array of event objects. The <code class="ph codeph">TransformEvents_xmlSample</code> include script that transforms events from XML format is provided as an example when the <span class="ph">Event Management</span> plugin is activated.</li></ul> For more information about authentication and data security, see <a class="xref" href="../task/configure-mid-web-server-extension.html" title="The MID Web Server is a MID Server extension that enables developing REST APIs to send events and metrics to the MID Server. The extension is leveraged by other MID Server extensions, such as Metric Intelligence, MID WebService Event Listener, and the Agent Client Collector websocket endpoint extension.">Configure the MID Web Server extension</a>.</div> </div> <div class="related-links"> <div class="linklist relinfo reltasks"><strong>Related tasks</strong><br /> <ul class="linklist"><li class="linklist"><a class="link" href="../task/send-events-via-web-service.html" title="You can use a web service interface, supported by ServiceNow, that operates on the JSON object as the data input and output format.">Pushing events to the instance using web service API</a></li></ul></div> </div> </body></html></div>