Skip to main content

Listing tasks

This section provides information on how to list tasks.

API reference:

Required scopes:

  • Taskurai.Task.Read

Prerequisites

Listing tasks

Use the following command to list tasks:

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

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:

PropertyTypeDefaultDescription
Offsetinteger0Start at the position to enumerate tasks
Limitinteger10Limit the number of items returned (maximum = 100)
OrderBystringOrder by field (format: fieldName:direction, direction: ASC, DESC)
IncludeCompletedbooleantrueInclude completed tasks
IncludeArchivedbooleanfalseInclude archived tasks
IncludeIsolatedbooleanfalseInclude isolated tasks (Local development mode)
IncludeUnlistedbooleanfalseInclude unlisted tasks (internal tasks)
CommandstringFilter tasks by command
ExternalIdstringFilter tasks by external ID
AccountIdstringFilter tasks by account ID
UserIdstringFilter tasks by user ID
CategoryContainsstringFilter tasks by category (case-insensitive)
SubjectContainsstringFilter tasks by subject (case-insensitive)
FilterIsolatedbooleanfalseFilter isolated tasks (local identifier required)
LocalIdentifierstringLocal identifier to filter isolated tasks

Order by field names:

Field nameDescription
createdTask created
modifiedTask modified
startedTask started
stoppedTask stopped
statusTask status
provisioningStateProvisioning state (status synonym)
config.commandTask command
config.externalIdExternal ID
config.accountIdAccount ID
config.userIdUser ID
config.categoryCategory
config.subjectSubject
config.descriptionDescription
progress.progressTask progress
progress.messageProgress message
result.summaryResult summary
result.outputResult output
error.codeError code
error.messageError message
archivedTask archived
postponedTask postponed
cancelledTask canceled
statusCodeTask status code
runCountTask run count

Order by direction:

DirectionDescription
ASCAscending
DESCDescending