Need simple example for Scripted REST API for POST and PUT method
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2021 11:43 PM
Hi All,
As I am new bee to integration, would like to understand the integration with simple scripts.
Could you please provide the example for Scripted REST API for POST and PUT method.
Regards,
Yashaswini
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2021 04:35 AM
Thank you for marking my response as helpful.
If my response helped you please mark it correct to close the question so that it benefits future readers as well.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2022 10:36 AM
I know this is very late, but for others that may find this thread and are looking for a simple example, I found one here: https://guide.blazemeter.com/hc/en-us/articles/360001849957-ServiceNow-Integration
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var apiKey = request.queryParams['apiKey'];
var secret = "<secret>";
if (apiKey == secret) {
var event = request.body.data;
var inc = new GlideRecord('incident');
inc.initialize();
var short_description = "Runscope Webhook - ";
short_description += event.test_name;
inc.short_description = short_description;
inc.description = event.bucket_name + " - " + event.test_name;
inc.work_notes = "Test run URL: " + event.test_run_url;
inc.number = event.test_run_id;
inc.state = 1;
inc.impact = 2;
inc.urgency = 2;
inc.priority = 2;
// optional - specific person to assign the incident to
// inc.assigned_to = "<email>";
inc.assignment_group.setDisplayValue("<group>");
var comments = "Runscope Test URL: " + event.test_url;
comments += "\nRunscope Test Run URL: " + event.test_run_url;
inc.comments = comments;
inc.insert();
} else {
gs.warn("Invalid API Key for Runscope Webhook");
}
// Runscope expects a 200 status code response back
response.setStatus(200);
})(request, response);