tasks->createTask() throws exception

The following PHP method isn’t workin in my class for me even though the $workspace_id and $project_id are valid (and were obtained using the SDK connected to my Asana account).

public function handle() {

        $task = $this->asana->tasks->createTask(
            [
                'workspace' => $workspace_id,
                'projects' => [$project_id],
                'name' => $content_story->title,
                'notes' => $content_story->description
            ],
            ['opt_pretty' => 'true']
        );

}

It returns the following exception:

Asana\Errors\InvalidRequestError : Invalid Request

at /home/…/vendor/asana/asana/src/Asana/Errors/AsanaError.php:28
24| switch ($response->code) {
25| case ForbiddenError::STATUS:
26| throw new ForbiddenError($response);
27| case InvalidRequestError::STATUS:

28| throw new InvalidRequestError($response);
29| case InvalidTokenError::STATUS:
30| throw new InvalidTokenError($response);
31| case NoAuthorizationError::STATUS:
32| throw new NoAuthorizationError($response);

Exception trace:

1 Asana\Errors\AsanaError::handleErrorResponse(Object(Httpful\Response))
/home/…/vendor/asana/asana/src/Asana/Client.php:98

2 Asana\Client::request(“POST”, “/tasks”)
/home/…/vendor/asana/asana/src/Asana/Client.php:247

Not sure exactly when you tried this but the first thing to note is that Asana just went through an outage over the past few hours. It’s resolved now so I would try this again now. That may not be the cause of your issue but it’s the first thing to be suspicious of.

2 Likes