我似乎無法將標籤添加到新的或現有的任務。Asana API:使用任務/ addTag或使用標籤創建任務時出現無效請求
我使用的是從GitHub的API在https://github.com/Asana/php-asana
%的文檔here,我設置的選項,併發射了API調用任務的端點。它失敗:
致命錯誤:在/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);
未捕獲的異常 '體位\錯誤\ InvalidRequestError' 有消息 '無效請求'這裏是發送到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
或data
或tags
無濟於事。
我發現問題....標籤被分配給工作區。因此,我從workspace-1/project-1/task-1複製到** workspace-2 **/project-1/task-1的標籤將無法工作,除非我首先在workspace-2中創建標籤。 – limeygent