# RunTask

Run the selected task according to the specified option.

Required User Role: See [Required Enterprise Manager permissions](https://help.qlik.com/en-US/enterprise-manager/May2026/Content/EnterpriseManager/EnterpriseManager_APIGuide/Introduction/AEMPermissions.htm).

## Syntax

`public AemRunTaskResp RunTask(` `AemRunTaskReq payload,` `string server,` `string task,` `AemRunTaskOptions option = AemRunTaskOptions.Option,` `int timeout = 30` `);`

## Parameters

Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| payload | AemRunTaskReq | - |
| Cdcposition | string | The `cdcposition` parameter can either be specified inline or in an external JSON file. The format for both is described in [Request body format](https://help.qlik.com/en-US/enterprise-manager/May2026/Content/EnterpriseManager/EnterpriseManager_APIGuide/NetAPI/api_runTask.htm#Body2) below.<br><br>Mandatory for all AemRunTask options. |
| server | string | The name of the server on which to run the task. |
| task | string | <ul> <li><span><span>Replicate</span>:</span> - The name of the task.</li> <li> <p><span><span>Compose</span>: </span>- The name of the task or workflow appended with a double underscore and the project name.</p> <p><span><span>Example: </span></span>&nbsp;</p> <p><span>mytask__myproject</span> </p> </li> </ul> |
| option | AemRunTaskOptions<br><br>`{RESUME_PROCESSING = 1,`<br>`RELOAD_TARGET = 2,`<br>`RESUME_PROCESSING_FROM_TIMESTAMP = 3,`<br>`METADATA_ONLY_RECREATE_ALL_TABLES = 4,`<br>`METADATA_ONLY_CREATE_MISSING_TABLES = 5,`<br>`RECOVER_USING_LOCALLY_STORED_CHECKPOINT = 6,`<br>`RECOVER_USING_CHECKPOINT_STORED_ON_TARGET = 7`<br>`RESUME_PROCESSING_FROM_POSITION = 8`<br>`}`<br><br>See also [Run options](https://help.qlik.com/en-US/enterprise-manager/May2026/Content/EnterpriseManager/EnterpriseManager_APIGuide/Shared/aem_rest_api_response_params.htm#Run). | For Replicate tasks, all options are supported.<br><br>For Compose tasks, specify AemRunTaskOptions.RESUME\_PROCESSING to run the task. |
| timeout | int | The time in seconds to wait for a response. |

## Request body format

### RESUME\_PROCESSING\_FROM\_TIMESTAMP

If the task [option](https://help.qlik.com/en-US/enterprise-manager/May2026/Content/EnterpriseManager/EnterpriseManager_APIGuide/Shared/aem_rest_api_response_params.htm#Run) is RESUME\_PROCESSING\_FROM\_TIMESTAMP, then the format should be:

JSON File Format:

`{"cdcposition":"timestamp"}`

Example:

`{"cdcposition":"2017-03-07T11:19:03"}`

Inline Format:

`"{\"cdcposition\":\"timestamp\"}"`

Example:

`"{\"cdcposition\":\"2017-03-07T11:19:03\"}"`

### RESUME\_PROCESSING\_FROM\_POSITION

If the task [option](https://help.qlik.com/en-US/enterprise-manager/May2026/Content/EnterpriseManager/EnterpriseManager_APIGuide/Shared/aem_rest_api_response_params.htm#Run) is RESUME\_PROCESSING\_FROM\_POSITION then, assuming the source database is SQL Server, the format should be:

JSON File Format:

`{"cdcposition":"LSN"}`

Example:

`{"cdcposition":"15000000040000037"}`

Inline Format:

`"{\"cdcposition\":\"LSN\"}"`

Example:

`"{\"cdcposition\":\"15000000040000037\"}"`

### RECOVER\_USING\_CHECKPOINT\_STORED\_ON\_TARGET

If the task [option](https://help.qlik.com/en-US/enterprise-manager/May2026/Content/EnterpriseManager/EnterpriseManager_APIGuide/Shared/aem_rest_api_response_params.htm#Run) is RECOVER\_USING\_CHECKPOINT\_STORED\_ON\_TARGET, then the format should be:

JSON File Format:

`{"cdcposition":"target_checkpoint"}`

Example:

`{"cdcposition":"Checkpoint:V1#1#timestamp:2017-02-14T12:34:44#0#0#*#0#0"}`

Inline Format:

`"{\"cdcposition\":\"target_checkpoint\"}"`

Example:

`"{\"cdcposition\":\"Checkpoint:V1#1#timestamp:2017-02-14T12:34:44#0#0#*#0#0\"}"`

## Return value

AemRunTaskResp

Return value parameters

| Parameter | Type | Description |
| --- | --- | --- |
| ErrorMessage | string | The description of the error. |
| State | AemTaskState<br><br>{<br><br>STOPPED = 0, RUNNING = 1,<br><br>ERROR = 2,<br><br>RECOVERY = 3<br><br>} | The current state of the task. |

## Errors

Error responses

| Error | Message | Description |
| --- | --- | --- |
| AEM\_TASK\_ALREADY\_RUNNING | Replicate task {task} on server {server} is already running. | The task cannot be run because it is already running. |
| AEM\_TASK\_IN\_RECOVERY | Replicate task {task} on server {server} cannot be run as it is in a recovery state. | The task cannot be run because it is in Recovery state. |
| AEM\_WRONG\_OPTION\_FOR\_CDCPOSITION | Replicate task {task] on server {server} cannot be run with cdcposition {position} and option {option}. Change the option to RESUME\_PROCESSING\_FROM\_TIMESTAMP, RESUME\_PROCESSING\_FROM\_POSITION, or RECOVER\_USING\_CHECKPOINT\_STORED\_ON\_TARGET | This error is returned when the specified option conflicts with the setting in the Advanced Run Options dialog in Replicate. |
| AEM\_CDC\_POSITION\_ERR\_FORMAT | The cdcposition parameter value for Replicate task {task} on server {server} is not in the correct format ('YYYY-MM-DDThh:mm:ssZ'). | The cdcPosition parameter must follow this format: YYYY-MM-DDThh:mm:ssZ<br><br>Parameters: task name and server name |
| AEM\_RUN\_TASK\_TIMEOUT | Replicate task {task} on server {server} timed out when requested to “Run”. | The task does not assume a Running state or any other steady state (error o stopped). |
| AEM\_RUN\_TASK\_INNER\_ERR | Replicate task {task} on server {server} encountered an error when requested to run. | Replicate experienced an error/exception when trying to run the task. |
| AEM\_RUN\_TASK\_NO\_SRC\_NO\_TRG | Replicate task {task} on server {server} has no source or target endpoints. | Task validation revealed that the task is missing a source and a target. |
| AEM\_RUN\_TASK\_NO\_SRC | Replicate task {task} on server {server} has no source endpoint. | Task validation revealed that the task is missing a source. |
| AEM\_RUN\_TASK\_TRG | Replicate task {task} on server {server} has no target endpoint. | Task validation revealed that the task is missing a target |
| AEM\_RUN\_TASK\_NOT\_FL\_NOR\_CDC | Replicate task {task} on server {server} cannot be run without at least one of the replication options enabled (Full Load, Apply Changes, or Store Changes). | Task validation of a unidirectional task revealed that the replication option definition for the task is missing (Full Load, Apply Changes, or Store Changes). |
| AEM\_RUN\_BIDI\_TASK\_NO\_FL\_NOR\_CDC | Replicate task {task} on server {server} cannot be run without at least one of the replication options enabled (Full Load or Apply Changes). | Task validation of a unidirectional task revealed that the replication option definition for the task is missing (Full Load, Apply Changes, or Store Changes). |