HomeGuidesAPI ReferenceChangelogDiscussions
GuidesiMIS ProfessionaliMIS EnterpriseClient SupportLog In
Guides
These docs are for v20.3.44. Click to read the latest docs for v20.3.192.

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:

  1. 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 
            } 
        ] 
    } 
}
  1. Enter the Name of the task where there is currently “new sp3”.
  2. Enter a new Description where there is currently "asi_GetCounter".
  3. Enter the StoredProcedureName where there is currently “asi_GetCounter”.
  4. 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" 
}
  1. Set the TaskDefinitionId to match the same ID returned in the response from the first call.
  2. If you already have the task created, you can run the task by simply making the second POST.

Contact us
Copyright © Advanced Solutions International, All rights reserved.