我正在尝试使用 Perl 在 Asana 中创建一个任务。我正在使用以下模块:
- WWW::Curl::简单
- JSON
- HTTP::请求
这是我的代码。
my %data = (
"data" => {
"workspace" => "##########", #$config->get('asana/workspace_id'),
"name" => "system error",
"assignee" => "me",
"projects" => "##########",
},
);
my @header = ('Authorization' => 'Bearer '.$personal_access_token));
my $curl = WWW::Curl::Simple->new();
my $uri = $config->get('asana/api_uri');
my $content = JSON->new->utf8->encode(\%data);
my $r = HTTP::Request->new(
'POST',
$uri,
\@header,
$content
);
my $res = $curl->request($r);
当我打印 $content 变量时,它看起来像这样。
{"data":{"workspace":"##########","name":"CBC FZDS Billing - System Error"}}
当我将 $r 变量打印为字符串时,它看起来像这样。(“个人访问令牌”显示我提供的个人访问令牌。)
POST https://app.asana.com/api/1.0/tasks
Authorization: Bearer <personal access token>
{"data":{"workspace":"##########","name":"CBC FZDS Billing - System Error"}}
结果$res->content
是:
'{"errors":[{"message":"missing `workspace` field, and no `parent` or `projects` specified","help":"For more information on API status codes and how to handle them, read the docs on errors: https://asana.com/developers/documentation/getting-started/errors"}]}'
任何想法为什么这表明工作区字段丢失?