Google HTTP Target tasks: Expect GoogleProtobufTimestamp when tried to setScheduleTime using php

I have been trying to add setScheduleTime to the cloud task. I have done the following:

use GoogleCloudTasksV2CloudTasksClient;
use GoogleCloudTasksV2HttpMethod;
use GoogleCloudTasksV2HttpRequest;
use GoogleCloudTasksV2Task;

class CreateRandomCloudTasksForLot
{
        putenv('GOOGLE_APPLICATION_CREDENTIALS=/service-account.json');
        $client = new CloudTasksClient();
        $queueName = $client->queueName($this->projectID, $this->location, $this->queue);

        $httpRequest = new HttpRequest();
        $httpRequest->setUrl('https://europe-west1-myproject.cloudfunctions.net/mybidfunction?id=1');        
        $httpRequest->setHttpMethod(HttpMethod::GET);
        
        if (isset($payload)) {
            $httpRequest->setBody($payload);
        }

        // Create a Cloud Task object.
        $task = new Task();
        $task->setScheduleTime(strtotime(Carbon::now()->addMinutes(20)));
        $task->setHttpRequest($httpRequest);

        // Send request and print the task name.
        $response = $client->createTask($queueName, $task);
        printf('Created task %s' . PHP_EOL, $response->getName());
}

It gives me the following error
image

Without passing the scheduled time I can create tasks but I need to schedule at a specific time. I cannot use appEngineTask because we can pass only RelativeUri. I want to pass the cloud function URL to execute. Can anyone please help me?

Source: Laravel

Leave a Reply