Custom Script Execution API
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.
GenericScriptExecution
| API | GenericScriptExecution |
|---|---|
| Purpose | To execute the python/powershell script. |
| API URL | https://<API URL>:<API Port>/iAutomateAPI/Request/ Execute/<OrgID>/ScriptID/<ScriptID> |
| Authentication type | Basic |
| Method Type | POST |
| Example: | https://<API URL>:<API Port>/iAutomateAPI/Request/Execute/1/ScriptID/1 |
|
Input JSON: It is dynamic as per the inputs required in Python/PowerShell script. Output:
|
|
Parameters Returned in Response of API
| Column | Column type | Value | Remarks |
|---|---|---|---|
| Statuscode | int |
|
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":
|
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:
Output:
{
"statusCode": 200,
"status": "Success",
"result": [
{
"number": " XXXXXXXX ",
"short_description": "Incident created from Supplier 1 ITSM using End User of Customer Company",
"sys_id": " XXXXXXXX ",
"closed_at": "2020-09-04 12:06:56",
"assignment_group": {
"link": "XXXXXXXX ",
"value": "XXXXXXXX "
},
"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:
Input JSON:
If (json.result)
{
for (varresult= [], i=0; i<json.result.length;i++)result.push(json.result[i]);
customJobject.dataCollectorNode.data.result=result
}