Execute from ServiceNow a RES ONE automation Runbook via REST Web services

iKnow-IT banner

Recently I was asked to create an interface between ServiceNow and RES ONE automation to execute RES RunBooks from a ServiceNow task.

If you create a module in RES and a Run Book that call's the created module(s) you get a "Run Book name" and a "Run Book GUID"

RES ONE Automation Run Book RES call

e.g. Run Book name: "RB_my_test_runbook_v0.1"

 

The power shell script that can be used in ServiceNow to call the REST Web Service from RES ONE Automation tool can looks like:

$username = "< user >"

$password = "< password >"

$password_base64 = ConvertTo-SecureString $password -AsPlainText –Force

$creds = New-Object System.Management.Automation.PSCredential ($username, $password_base64)

 

$json = @"

{

"Description":"Job from WebApi running RB_my_test_runbook_v0.1",

"When":{

"ScheduledDateTime":"\/Date(928149600000+0000)\/",

"Immediate":true,

"IsLocalTime":true,

"UseWakeOnLAN":true

},

"What":[{

"ID":"{< Run Book GUID >}",

"Type":2,

"Name":"RB_my_test_runbook_v0.1"

}],

"Who":[{

"ID":"String content",

"Type":0,

"Name":"String content"

}],

"Parameters":[{

"Identifier":"String content",

"Type":2,

"TaskContainerGuid":"<Run Book GUID>",

"TaskContainerName":"RB_my_test_runbook_v0.1",

"JobGuid":"{00000000-0000-0000-0000-000000000000}",

"JobName":"String content",

"JobParameters":[{

"Name":"< Run Book pakameter >",

"Type":0,

"Description":"String content",

"Value1":"<imput variable used in runbook parameter>",

"Value2":"String content",

"Value3":"String content",

"Hint":"String content",

"Selection":"String content"

}]

}]

}

"@

 

$response = Invoke-RestMethod 'http://<server>/Dispatcher/SchedulingService/jobs' -Method Post -Credential $creds -Body $json -ContentType 'application/json'