I can't seem to be able to add tags to new or existing tasks.
I'm using the API from github at https://github.com/Asana/php-asana
Per the docs here, I set up the options and fired up the API call to the task endpoint. It fails with:
Fatal error: Uncaught exception 'Asana\Errors\InvalidRequestError' with message 'Invalid Request' in /mydir/asana/Asana/Errors/AsanaError.php:29
// create new task
$newTaskOptions = array(
'name' => $taskName,
'notes' => $taskNotes,
'projects' => [11111111115445],
'tags' => [11111119991, 11111119992] // without this, the task is created ok
);
$newTask = $client->tasks->create($newTaskOptions);
Here is the object that is sent to the request
procedure:
array(2) {
["headers"]=> array(1) {
["content-type"] => string(16) "application/json"
}
["data"]=> array(2) {
["data"]=> array(4) {
["name"]=> string(17) "module 1 - task 1"
["notes"]=> string(32) "description of module 1 - task 1"
["projects"]=> array(1) {
[0]=> int(11111111115445)
}
["tags"]=> array(2) {
[0]=> int(11111119991)
[1]=> int(11111119992)
}
}
["options"]=> array(0) {
}
}
}
Even with their example of [ { id: 59746, name: 'Grade A' }, ... ]
(using the correct tag ids and names), it still errors out. Actually, it throws a syntax error at the first "{".
Next, if I try tasks/taskid/addTag
to an existing task, I receive a similar error. Here's this piece of code below.
foreach ($tags as $tag){
$newTag = $client->tasks->addTag($newTask->id, array('tag' => $tag));
}
The second part of the addTag
command requires an array, and according to the documentation uses the tag
as the array key. I tried other keys such as text
or data
or tags
to no avail.
Here is the issue....tags are assigned to a workspace. So the tags being copied from workspace-1/project-1/task-1 to workspace-2/project-1/task-1 would not work UNLESS the tag was first created in workspace-2.
Once the tag had been created in the destination workspace, the code worked flawlessly.