Running a task with a stored procedure
How to run a task with a stored procedure through the iMIS API.
The following example outlines how you can run a task with a stored procedure through the iMIS API:
- Create the Process Automation task for the stored procedure by using a POST to https://{{URL}}/api/TaskDefinition with a body like the following:
{
"$type": "Asi.Soa.Communications.DataContracts.TaskDefinitionData, Asi.Contracts",
"Name": "new sp3",
"Description": "",
"Priority": 0,
"TaskType": 1,
"Triggers": {
"$type": "Asi.Soa.Communications.DataContracts.TaskDefinitionTriggerDataCollection, Asi.Contracts",
"$values": []
},
"Evaluations": {
"$type": "Asi.Soa.Communications.DataContracts.TaskDefinitionEvaluationDataCollection, Asi.Contracts",
"$values": []
},
"DataSources": null,
"Actions": {
"$type": "Asi.Soa.Communications.DataContracts.TaskDefinitionActionDataCollection, Asi.Contracts",
"$values": [
{
"$type": "Asi.Soa.Communications.DataContracts.TaskDefinitionActionStoredProcedureData, Asi.Contracts",
"ActionTypeName": "StoredProcedure",
"Description": "asi_GetCounter",
"StoredProcedureName": "asi_GetCounter",
"EnableTriggerIdsAsParameters": false,
"ActionNotification": null
}
]
}
}
- Enter the Name of the task where there is currently “new sp3”.
- Enter a new Description where there is currently "asi_GetCounter".
- Enter the StoredProcedureName where there is currently “asi_GetCounter”.
- Execute the stored procedure with the following POST to the https://{{URL}}/api/TaskDefinition/_execute endpoint:
{
"$type": "Asi.Soa.Communications.DataContracts.TaskRequest, Asi.Contracts",
"TaskDefinitionId": "5ebf93a7-4069-4a43-b8c9-be6e8bd4e782",
"EntityTypeName": "TaskDefinition",
"OperationName": "TaskAdhocRequest"
}
- Set the TaskDefinitionId to match the same ID returned in the response from the first call.
- If you already have the task created, you can run the task by simply making the second POST.
Updated over 4 years ago