Batch request using PHP

Hello,

I’m trying to use the PHP Asana library to make a batch request but I keep getting an error and I’m not sure what I;m doing wrong.

I simply want to change the name of a task, just for testing, and here is what I have:

require_once 'vendor/autoload.php';
$client = Asana\Client::accessToken(API_KEY);

$data = [
 'actions' => [
   [
     'method' => 'post',
     'relative_path' => '/tasks/1198493609235160',
     'data' => [
       'name' => 'test 123123123'
     ]
   ]
 ]
];

$request = $client->post( '/batch', $data, array('opt_pretty' => 'true' ));

And the error that I’m getting is:

Array
(
  [0] => stdClass Object
    (
      [body] => stdClass Object
        (
          [errors] => Array
            (
              [0] => stdClass Object
                (
                    [message] => No matching route for request
                    [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
                )
            )
        )
      [status_code] => 404
      [headers] => stdClass Object
        (
        )
    )
)

Any ideas what I’m missing here?

Hi, I don’t know much about PHP, but objects and arrays are both defined using the same character? $data is an object, and actions is an array of objects. data is also an object not an array. But I may be wrong, I never did any PHP…

Is it possible that you call should looks like:
$data = (
‘actions’ =>
[
( ‘method’ => ‘post’,
‘relative_path’ => ‘/tasks/1198493609235160’,
‘data’ => (
‘name’ => ‘test 123123123’
)
)
]
);