Custom Script Execution API

The Custom Script Execution API allows for the execution of Python or PowerShell scripts through the API. It provides a URL for executing the script, authentication type, method type, input JSON format, and output format.

API version V1.0

This API is used for complex integrations where multiple APIs are required to be executed which can be written in a python/powershell script and can be executed through the API.

API: GenericScriptExecution
Purpose: To execute the python/powershell script.
API URL: http://<API URL>:<API Port>/iAutomateAPI/Request/ Execute/<OrgID>/ScriptID/<ScriptID>
Authentication type: Basic
Method Type: POST
Example: http://localhost:26240/iAutomateAPI/Request/ Execute/1/ScriptID/1

Input JSON: It is dynamic as per the inputs required in python/powershell script

Eg: {

"key": "123",

"URL": "http://localhost/rest/api/2/issue/",

"assignee_name": "user",

"release_comment":"Ticket_released_from_BigFix Runbook AI"

}

Output:

Column Column type value Remarks
statusCode int

Success = 200,

Error = 300,

RequiredAttributeValueMissing = 400,

Unauthorized = 401

This field provide status code
status string Success/Fail This field provide status
message string null or message in case of not success
result object

"result": [

{

"number": "INC0"}]

This field provide the response of the python/powershell script.
data string null

If the above custom script API is used to fetch tickets while creating data source, then the JsResponseConverter for the CollectIncident job will be changed for the response like below:

{

"statusCode": 200,

"status": "Success",

"result": [

{

"number": "INC01",

"short_description": "Incident created from Supplier 1 ITSM using End User of Customer Company",

"sys_id": "ce004ad21",

"closed_at": "2020-09-04 12:06:56",

"assignment_group": {

"link": "https://dryicegbpdevdemo.service-now.com/api/now/v1/table/sys_user_group/b9ddeb331ba770d8f5d475d8cd4bcb14",

"value": "b9ddeb331ba770d8f5d475d8cd4bcb14"

},

"incident_state": "9",

"description": "Incident created from Supplier 1 ITSM using End User of Customer Company",

"sys_updated_on": "2022-06-27 11:17:11",

"category": "Server",

"sys_created_on": "2020-09-04 12:06:56"

}

]

}

To Configure the JsResponseConverter, go to the CollectIncidents job after creating data source and in the job’s parameter, update below value for the JsResponseConverter field:

if(json.result){for(var result=[],i=0;i<json.result.length;i++)result.push(json.result[i]);customJobject.dataCollectorNode.data.result=result}