Listing tasks
This section provides information on how to list tasks.
API reference:
Required scopes:
Taskurai.Task.Read
Prerequisites
- You have completed the Setup sample application tutorial.
Listing tasks
Use the following command to list tasks:
- C#
var tasks = await taskurai.ListTasksAsync();
Console.WriteLine(JsonSerializer.Serialize(tasks, serializerOptions));
Next, run the console application to validate:
dotnet run
The expected output should be:
[
{
"Id": "fe09b9a9-1864-4948-aab3-358e0202c2c8",
"Config": {
"Command": "testCommand",
"Arguments": [
{
"Name": "arg1",
"Value": "abc-123"
}
],
"Category": "Console app",
"Subject": "Samples",
"Description": "This is a test task",
"ExternalId": "my-id-123456",
"Id": "fe09b9a9-1864-4948-aab3-358e0202c2c8",
"Data": {"Name":"Test","Value":"Some value","Properties":["Some property","Another property"]}
},
"Created": "2023-06-23T11:45:10.6112456+00:00",
"Modified": "2023-06-23T11:45:22.6386227+00:00",
"Started": "2023-06-23T11:45:22.6386227+00:00",
"RunStarted": "2023-06-23T11:45:22.6386227+00:00",
"Stopped": "2023-06-23T11:45:22.6386227+00:00",
"Status": "Succeeded",
"ProvisioningState": "Succeeded",
"StatusCode": 200,
"RunCount": 1,
"Progress": {
"Progress": 100,
"Message": "Task finished."
},
"Result": {
"Details": [],
"Output": "https://storage.co/id",
"OutputDetails": []
},
"Archived": false,
"Postponed": false,
"Cancelled": false
},
{
"Id": "5a4be4fe-768b-47a9-8555-98dc5b1c9270",
"Config": {
"Command": "generateOrderConfirmation",
"Arguments": [
{
"Name": "orderId",
"Value": "1dff3887-29e8-4ccb-99f0-a15537e4b09e"
}
],
"Category": "Create order",
"Subject": "Creating order 1dff3887-29e8-4ccb-99f0-a15537e4b09e for customer mycustomer",
"Id": "5a4be4fe-768b-47a9-8555-98dc5b1c9270"
},
"Created": "2023-06-28T13:10:07.8041305+00:00",
"Modified": "2023-07-03T12:25:45.6557001+00:00",
"Started": "2023-07-03T12:25:45.6557001+00:00",
"RunStarted": "2023-07-03T12:25:45.6557001+00:00",
"Status": "Running",
"RunCount": 1,
"ProvisioningState": "Running",
"StatusCode": 202,
"Archived": false,
"Postponed": false,
"Cancelled": false
},
...
]
Customize list options
- C#
You can customize the list options using the ListTasksOptions like this:
var tasks = await taskurai.ListTasksAsync(new ListTasksOptions()
{
OrderBy = "created:DESC",
Offset = 10,
Limit = 10,
});
Console.WriteLine(JsonSerializer.Serialize(tasks, serializerOptions));
Overview of the task list options:
Property | Type | Default | Description |
---|---|---|---|
Offset | integer | 0 | Start at the position to enumerate tasks |
Limit | integer | 10 | Limit the number of items returned (maximum = 100) |
OrderBy | string | Order by field (format: fieldName:direction, direction: ASC, DESC) | |
IncludeCompleted | boolean | true | Include completed tasks |
IncludeArchived | boolean | false | Include archived tasks |
IncludeIsolated | boolean | false | Include isolated tasks (Local development mode) |
IncludeUnlisted | boolean | false | Include unlisted tasks (internal tasks) |
Command | string | Filter tasks by command | |
ExternalId | string | Filter tasks by external ID | |
AccountId | string | Filter tasks by account ID | |
UserId | string | Filter tasks by user ID | |
CategoryContains | string | Filter tasks by category (case-insensitive) | |
SubjectContains | string | Filter tasks by subject (case-insensitive) | |
FilterIsolated | boolean | false | Filter isolated tasks (local identifier required) |
LocalIdentifier | string | Local identifier to filter isolated tasks |
Order by field names:
Field name | Description |
---|---|
created | Task created |
modified | Task modified |
started | Task started |
stopped | Task stopped |
status | Task status |
provisioningState | Provisioning state (status synonym) |
config.command | Task command |
config.externalId | External ID |
config.accountId | Account ID |
config.userId | User ID |
config.category | Category |
config.subject | Subject |
config.description | Description |
progress.progress | Task progress |
progress.message | Progress message |
result.summary | Result summary |
result.output | Result output |
error.code | Error code |
error.message | Error message |
archived | Task archived |
postponed | Task postponed |
cancelled | Task canceled |
statusCode | Task status code |
runCount | Task run count |
Order by direction:
Direction | Description |
---|---|
ASC | Ascending |
DESC | Descending |