- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2018 11:45 AM
I followed the instructions provide in the link below to create a Webhook and sucessfully posted an Alert to the system logs .
https://community.servicenow.com/community?id=community_blog&sys_id=886d2a29dbd0dbc01dcaf3231f9619b0
How do i create an incident for the messages /Alerts received through the webhook.
Thanks
Senthil
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2018 06:17 PM
Hi Senthil,
In the scripted API that you created as part of the instructions in that blog... instead of doing a log entry, you actually can create the incident.
How?
It's very simple... just include something like the following before or after where you do the log entry...
var grIncident = new GlideRecord('incident');
grIncident.initialize();
grIncident.short_description = 'Incident created from WebHook';
grIncident.description = request.body.dataString;
//the above is just an example. you can parse the request body and fill up the various incident fields depending on the data that you have in your payload
grIncident.insert();
//and Voila! your Incident is created
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2018 06:17 PM
Hi Senthil,
In the scripted API that you created as part of the instructions in that blog... instead of doing a log entry, you actually can create the incident.
How?
It's very simple... just include something like the following before or after where you do the log entry...
var grIncident = new GlideRecord('incident');
grIncident.initialize();
grIncident.short_description = 'Incident created from WebHook';
grIncident.description = request.body.dataString;
//the above is just an example. you can parse the request body and fill up the various incident fields depending on the data that you have in your payload
grIncident.insert();
//and Voila! your Incident is created
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2018 06:20 PM
Hi Senthil,
Perhaps to elaborate... you can use pathParams and queryParams to parse / pull the specific attributes of the request payload.
Thanks,
Berny
source: https://docs.servicenow.com/bundle/london-application-development/page/app-store/dev_portal/API_reference/ScriptableServiceRequest/concept/c_ScriptableServiceRequest.html?cshalt=yes
RESTAPIRequest - pathParams
The path parameters passed in the request URI.
Name | Type | Description |
---|---|---|
pathParams | Object | The path parameters as a script object. Available path parameters depend on the web service configuration. |
In this example, the scripted REST API endpoint follows this format: https://instance.service-now.com/api/now/myservice/{tableName}/{id}. The request being processed uses this URL:https://instance.service-now.com/api/now/myservice/myApp_table/1234.
var pathParams = request.pathParams; var tableName = pathParams.tableName; //‘myApp_table’ var id = pathParams.id; //‘1234’
RESTAPIRequest - queryParams
The query parameters from the web service request.
Name | Type | Description |
---|---|---|
queryParams | Object | The query parameters from the web service request. |
In this example, the request being processed uses this URL: https://<instance_rest_endpoint>?active=false&name=now. Note the active and name parameters.
var queryParams = request.queryParams; var isActiveQuery = queryParams.active; //false var nameQueryVal = queryParams.name; //‘now’
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2018 06:23 PM
I hope this helps Senthil!! Have a great day! 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2018 11:25 PM
Berny,
Thanks a lot for the help and your time .
I will try out the instructions provided and keep you posted on the outcome .
Senthil