我正在尝试使用自定义字段在Asana中创建任务

时间:2018-06-25 07:21:28

标签: php asana asana-api

我正在尝试使用自定义字段数据在asana中创建任务,但它给了我致命错误, 如果我不附加自定义字段,则正确创建任务。  但是我想用自定义字段创建任务,这意味着我也想自定义字段数据

require 'vendor/autoload.php';
use Asana\Client;


// this is access token
$ASANA_ACCESS_TOKEN = '************************';
$option = array(array(
    "id" => "720739169509386",
    "name" => "Phone",
    "text_value" => "9806130204",
    "type" => "text",
),
array(
    "id" => "720739169509388",
    "name" => "Contact",
    "text_value" => "girish",
    "type" => "text",
)
);

$client = Asana\Client::accessToken($ASANA_ACCESS_TOKEN);
$me = $client->users->me();

$workspaceId = $me->workspaces[0]->id;

$demoTask = $client->tasks->createInWorkspace($workspaceId, array(
"name" => "demo task created at " . date('m/d/Y h:i:s a'),
"projects" => array('720702522904258'),
'assignee' => 'test@test.com',
'notes' => 'Lorem Ipsum is simply dummy text of the printing and',
'custom_fields' => $option,
    ));

echo "Task " . $demoTask->id . " created.\n";`

这是我得到的错误:

Fatal error: Uncaught exception 'Asana\Errors\InvalidRequestError' with message 'Invalid Request' in C:\xampp\htdocs\cssindiaonline\wp-content\themes\shopper\asana_new\src\Asana\Errors\AsanaError.php:39 Stack trace: #0 C:\xampp\htdocs\cssindiaonline\wp-content\themes\shopper\asana_new\src\Asana\Client.php(77): Asana\Errors\AsanaError::handleErrorResponse(Object(Httpful\Response)) #1 C:\xampp\htdocs\cssindiaonline\wp-content\themes\shopper\asana_new\src\Asana\Client.php(150): Asana\Client->request('POST', '/workspaces/626...', Array) #2 C:\xampp\htdocs\cssindiaonline\wp-content\themes\shopper\asana_new\src\Asana\Resources\Gen\TasksBase.php(55): Asana\Client->post('/workspaces/626...', Array, Array) #3 C:\xampp\htdocs\cssindiaonline\wp-content\themes\shopper\asana_new\index.php(37): Asana\Resources\Gen\TasksBase->createInWorkspace('626590817891949', Array) #4 {main} thrown in C:\xampp\htdocs\cssindiaonline\wp-content\themes\shopper\asana_new\src\Asana\Errors\AsanaError.php on line 39

1 个答案:

答案 0 :(得分:0)

我的感觉是您正在尝试同时创建自定义字段和任务,不是吗?