Updating tasks
This section provides information on how to update tasks.
A task can be updated at any stage of its lifetime. You can report progress while a job is running.
API reference:
Required scopes:
Taskurai.Task.Update
Prerequisites
- You have completed the Setup sample application tutorial.
Partial updates
The update command can apply partial updates depending on the values passed into the UpdateTaskInput object.
Updating an existing task
To update an existing task in your sample application, add the following code:
- C#
var serializerOptions = new JsonSerializerOptions()
{
WriteIndented = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault,
Converters ={
new JsonStringEnumConverter()
}
};
var updateInput = new UpdateTaskInput()
{
Progress = new TaskProgress()
{
Message = "In progress",
Progress = 10.0
}
};
var updateTask = await taskurai.UpdateTaskAsync(previouslyCreatedTaskId, updateInput);
Console.WriteLine(JsonSerializer.Serialize(updateTask, serializerOptions));
Next, run the console application to validate:
dotnet run
The expected output should be:
{
"Id": "33b96181-795d-459c-9939-8cd9d489446b",
"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": "33b96181-795d-459c-9939-8cd9d489446b",
"Data": {"Name":"Test","Value":"Some value","Properties":["Some property","Another property"]}
},
"Created": "2023-06-30T10:08:59.6555697+00:00",
"Modified": "2023-06-30T10:09:00.2940743+00:00",
"Started": "2023-06-30T10:09:00.2940743+00:00",
"RunStarted": "2023-06-30T10:09:00.2940743+00:00",
"Status": "Running",
"RunCount": 1,
"ProvisioningState": "Running",
"Progress": {
"Progress": 10,
"Message": "In progress"
},
"Archived": false,
"Postponed": false,
"Cancelled": false
}