update_task

The unit/update_task request allows you to edit tasks.

Copied!
svc=unit/update_task&params={
	"itemId": <long>,
	"taskId": <text>,
	"props": {
		"key1": <long>,
		"key2": <text>,
		.....
	}
}

Request example:

Copied!
https://hst-api.wialon.com/wialon/ajax.html?sid=5e860dbe24e3d704ffb196d0733ec714&svc=unit/update_task&params={
"itemId": 1514,
"taskId": "6f6aeeebad9ebe64bda86924f8d379d8e6b06bd690c53da4aab526c5e221bdb266b52a50",
"props": {
"task_status": 2,
"task_priority": 3
}
}

Parameters

The following parameters are required:

Name Description
itemId The ID of the unit.
taskId The ID of the task (a string hash).
props The object of properties to be updated (key-value pairs). Include only those properties that you want to update, because each update fully replaces the corresponding existing property. Below is the list of flags that you can include in this parameter to update the task properties.

Flags

Flag Description
task_status The status of the task. Acceptable values are:

  • 1 (New)
  • 2 (To do)
  • 3 (In progress)
  • 4 (Paused)
  • 5 (Rejected)
  • 6 (Done)

If you change the task status from Done or Rejected to any other status, or from any other status to Done, Rejected, or Paused, a comment is required.
task_priority The priority of the task. Acceptable values are:
  • 1 (Low)
  • 2 (Medium)
  • 3 (High)
task_assignee The ID of the user to whom the task is assigned.
task_comments The array of task comments. The comment field must not be empty and must not exceed 500 characters.
task_params A JSON object containing additional task parameters. Supported keys:
  • filled — amount of fuel filled
  • charged — amount of energy charged
  • cost — task cost
  • engine_hours — vehicle engine hours
  • mileage — vehicle mileage.

If a value is already set, you can change it, but not delete it.

The task_comments array must be structured as follows:

Copied!
[
    {
        timestamp: 13243,
        assignee: 1564,
        comment: "Hello world"
    }, 
    {
        timestamp: 13244,
        assignee: 1564,
        comment: "Hello world 2"
    }
]

If a comment has been previously added to the task, but its ID is not included in the array, the comment will be deleted.

Adding a comment

To add a comment, pass a JSON of the following format in the comment array:

Copied!

{ "comment": "your comment text" }

Editing a comment

To edit a comment, specify its ID in the comment array and include the new comment text:

Copied!

{ "id": 23, "comment": "new comment text" }

Deleting a comment

To delete a comment, remove it from the comment array.

Adding or editing additional parameters

To add or edit additional task parameters, include the task_params object in the props parameter with the desired key-value pairs:

Copied!
{
    "itemId": 1514,
    "taskId": "6f6aeeebad9ebe64bda86924f8d379d8e6b06bd690c53da4aab526c5e221bdb266b52a50",
    "props": {
        "task_params": {
            "filled": 50.5,
            "mileage": 125.8,
            "cost": 150
        }
    }
}

The filled and mileage values should be provided in the unit’s current measurement system (SI, US, imperial, or metric with gallons).

Response

If the request is completed successfully, an empty response is returned.

Copied!
{ }

Otherwise, an error code is returned. Example:

Copied!
{
    "error": 5
}

Error codes

Error Code Description
1 Invalid input parameters.
2 No access to the unit. The following access rights are required:
  • View object and its basic properties
  • Request reports and messages
  • Edit tasks
  • Edit task status and manage comments (required only for status updates and comment management).
3 No access to the user. The Act on behalf of this user access right to the task assignee is required.
4 Failed to find the task with the specified ID.
5 A comment is required.
6 Invalid comment ID.
7 Unknown error.

If you find a mistake in the text, please select it and press Ctrl+Enter.

Report a mistake

Your message was sent. Thank you!

An error occurred while submitting the form