title: Sending a JSON payload to a Google Cloud Task
body: <p>I'm likely missing something incredibly obvious, but in the project I'm working on I've got to send many jobs from a CSV of info to be processed asynchronously and Google App Engine's current way is through their new (beta) Cloud Tasks mechanism.</p>
  
  <p>It will accept a payload as part of the task, so I was going to send a JSON array with each job's pertinent data... except that the only way to dictate the <code>"Content-Type: application/json"</code> header is during creation of the task object.</p>
  
  <p>I'm using Google's own cloud-tasks 0.5.0 library.</p>
  
  <p>Here is what I've been attempting, since it seems this is how most other non-cURL HTTP POST requests would accept the Content-Type header...</p>
  
  <pre><code>require_once 'vendor/autoload.php';
  
  use Google\Cloud\Tasks\V2beta3\AppEngineHttpQueue;
  use Google\Cloud\Tasks\V2beta3\CloudTasksClient;
  use Google\Cloud\Tasks\V2beta3\Queue;
  use Google\Cloud\Tasks\V2beta3\Task;
  
  &lt;&lt;&lt; ...lots of cruft omitted... &gt;&gt;&gt;
  
          $json_payload = json_encode(
              array(
                  "batch" =&gt; $operation_time,
                  "order" =&gt; $csvln[0],
                  "customer" =&gt; $csvln[1],
                  "email" =&gt; $csvln[2],
                  "salesperson" =&gt; $csvln[3]
              )
          );
  
          //Create each of the tasks in the queue
          $options = [
              'http' =&gt; [
                  'header'  =&gt; "Content-type: application/json",
                  'method'  =&gt; 'POST',
                  'content' =&gt; $json_payload
              ]
          ];
  
          $task = new Task($options);
  </code></pre>
  
  <p>Any help would be immensely appreciated!</p>