我似乎无法为新任务或现有任务添加标签。
我在https://github.com/Asana/php-asana使用来自 github 的 API
根据此处的文档,我设置了选项并启动了对任务端点的 API 调用。它失败了:
致命错误:在 /mydir/asana/Asana/Errors/AsanaError.php:29 中出现未捕获的异常“Asana\Errors\InvalidRequestError”和消息“Invalid Request”
// 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);
这是发送到request
过程的对象:
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) {
}
}
}
即使使用他们的示例[ { id: 59746, name: 'Grade A' }, ... ]
(使用正确的标签 ID 和名称),它仍然会出错。实际上,它会在第一个“{”处引发语法错误。
接下来,如果我尝试tasks/taskid/addTag
执行现有任务,我会收到类似的错误。下面是这段代码。
foreach ($tags as $tag){
$newTag = $client->tasks->addTag($newTask->id, array('tag' => $tag));
}
该addTag
命令的第二部分需要一个数组,并根据文档使用tag
作为数组键。我尝试了其他键,例如text
ordata
或tags
无济于事。