I am attempting to create a task in Asana using Perl. I am using the following modules:
- WWW::Curl::Simple
- JSON
- HTTP::Request
Here is my code.
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);
When I print the $content variable, it looks like this.
{"data":{"workspace":"##########","name":"CBC FZDS Billing - System Error"}}
When I print the $r variable as a string, it looks like this. ("personal access token" displays my the personal access token that I have provided.)
POST https://app.asana.com/api/1.0/tasks
Authorization: Bearer <personal access token>
{"data":{"workspace":"##########","name":"CBC FZDS Billing - System Error"}}
The result from $res->content
is:
'{"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"}]}'
Any ideas why this is indicating that the workspace field is missing?