I have created two watches on two folders in my shared drives. I want to be notified if someone adds or updates any file in the folders.
It was working for about 1 month. Now I noticed, the Google does not hit my URL if something changed in the folders. I have tried to add a file, delete a file, change the name of a file and nothing triggers the change event.
Google hits my URL only if I'm renewing (creating new) watch on the folders. Then I don't know about API until I renew again.
I use PHP lib:
public function createFileWatch(string $fileId, ?string $token = NULL): Google_Service_Drive_Channel
{
$optParams = [
'fields' => '*',
'supportsAllDrives' => TRUE,
];
$channel = new Google_Service_Drive_Channel();
$channel->setId(Random::generate());
$channel->setType('web_hook');
$channel->setAddress(self::WATCH_REQUEST_URL);
$channel->setExpiration((new DateTime('+1 week'))->getTimestamp() * 1000);
if ($token) {
$channel->setToken($token);
}
return $this->drive->files->watch($fileId, $channel, $optParams);
}