When downloading files via the Google Drive API in PHP, my HTTP request returns a 200 status yet the response body is empty. I am seeking insights into this inconsistency.
function retrieveDocument($docId) {
try {
$info = $this->driveService->getMetadata($docId);
$link = $info->downloadLink;
if ($link) {
$client = new HttpClientRequest($link, 'GET');
$result = $client->execute();
if ($result->status === 200) {
$info->fileContent = $result->body;
} else {
return null;
}
} else {
return null;
}
return json_encode($info);
} catch (DriveException $ex) {
error_log('Error downloading file: ' . $ex->getMessage());
throw $ex;
}
}