Google Drive API file download shows 200 status but returns no data

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;
    }
}

In my experience, encountering a 200 status with an empty body often points to nuances with the file type or the API request itself. I once hit a similar issue when downloading a Google Docs file and realized that the download URL does not return raw content like a typical file download. In such cases, the API expects to receive an export link instead of the download link, so verifying whether the file type requires a conversion or export process is essential. Adjusting the request to handle Google Docs exports resolved the problem for me.