CreateTask

Updated at:

Description: Creates a service-based task.

Endpoint: /rpa/openapi/raas/task/CreateTask

Method: POST

Usage notes:

  • Task queue limits: The maximum number of pending tasks is 100 per robot and 1,000 per robot group. If these limits are exceeded, the API call to create a task fails.

  • Request parameters must be passed in the request body.

  • This API supports idempotent calls. For more information, see Idempotent Call.

Limitations:

Important

For details about API call limits, see Call limits.

Request parameters:

Parameter

Type

Required

Example

Description

AppId

String

Yes

2e8e34bf-****-****-****-e1d0add3d95e

  • The application ID. You can find the application ID on the Enterprise Applications > Enterprise Application List page in the RPA console.

Note

Unlike local robots, which have application permission restrictions, a service-based task can run any RPA application within the tenant.

AppParams

Array of JSON. Serialization format: simple

No

[{"name":"param1","value":""},{"name":"param2","value":""}]

The input parameters that are required to run the application. The maximum size is 40 KB.

AllocateMode

String

No

auto

  • The robot allocation mode. Valid values: auto (automatic allocation) and manu (manual specification).

  • If this parameter is not specified, the system uses auto by default and automatically assigns a robot from a robot group.

  • To run the task on a specific robot, set this parameter to manu and specify the RobotId.

PackId

String

No

bv2XPrDl

  • This parameter applies when AllocateMode is set to auto or is not specified.

  • If you omit this parameter, the system uses the default robot group for service-based robots.

  • To use a specific robot group, provide its ID.

RobotId

String

No

11DC81******4E463B1E538436035653

  • This parameter applies when AllocateMode is set to manu.

  • You must provide the ID of the specific robot to use.

TaskPriority

Integer

No

85

The task priority. An integer from 1 to 100, where 100 is the highest priority. The default value is 50.

CallbackUrl

String

No

http://example.callback.com/example

The callback URL. You must provide a full URL that supports HTTP or HTTPS. Callbacks are sent as POST requests only.

The RPA service initiates callback requests. Ensure network connectivity between the RPA service and your callback URL.

The system retries a failed callback up to three times. You can view the callback results on the Task Details page in the RPA console. For more information, see the callback details below.

AppVersion

String

No

1.0.0

The version of the application to run.

Callback details:

If you specify a valid HTTP or HTTPS callback URL when you create a task, the system triggers a callback when the task status changes. The system retries a failed callback up to three times.

If your callback API requires authentication, we recommend that you use HTTPS and pass a token in the query string of the URL. For example: https://example.callback.com/example?token=12345.

Note
  1. In a callback request, the Content-Type header is application/x-www-form-urlencoded.

  2. Callbacks are sent as POST requests only, with the payload in the request body.

The body of the callback request has the following structure:

Parameter

Type

Example

Description

taskId

String

537a6966-****-****-****-f80976e2f5a6

The task ID.

taskStatus

String

complete

The new status of the task. Valid values:

  • terminated: The task ended with an error.

  • complete: The task finished successfully.

  • running: The task is in progress.

taskResult

String

cnBh5pyN5******L5py65Zmo5Lq6

  • The application's execution result. Your automation workflow must be configured to generate this result. For usage and limitations, see task_result.

  • This field is present only when taskStatus is complete. The content is Base64-encoded.

Example body:

taskId=537a6966-****-****-****-f80976e2f5a6&taskStatus=running&taskResult=cnBh5pyN5Yqh******65Zmo5Lq6

You can view callback records initiated by the RPA service in the RPA console under Service-based Robots > Task Management > Task Details, as shown in the following figure.

image

Response parameters:

For information about the common response structure, see API Reference overview. The following table describes the fields in the data object.

Parameter

Type

Example

Description

TaskId

String

48bb0d07-****-****-****-cbe75d646bb5

The task ID.

Request example:

POST /rpa/openapi/raas/task/CreateTask?<common_request_parameters> HTTP/1.1Host: console-rpa.aliyun.comContent-Type: application/json{  "AllocateMode": "auto",  "AppId": "0925860d-b652-****-****-****-446d0cdb2ff5",  "PackId": "nO5494bS",  "TaskPriority": 39}

Response example:

{
	"requestId": "95ea6575-****-****-****-4f949626b3fd",
	"success": true,
	"code": 0,
	"msg": "Success",
	"msgCode": "result.success",
	"data": {
		"TaskId": "cde18c63-****-****-****-8623299a0116"
	},
	"pager": null,
	"instanceId": null
}