Unable to download `googledocs` file via API

Hello,

I get the following error when I try to call the download endpoint with any file ID whose remote location is googledocs.

{"success":false,"error":"unauthorized access","errorCode":401,"error_info":"Please check developers.pipedrive.com"}

Is there a way to programatically get these types of files out of Pipedrive?

Hi @Vitaly_Galchenko
Welcome to the community :wave:
For files that are not stored in Pipedrive, you would notice two relevant parameters remote_location and remote_id

image

You need to access the file in Google Drive via Drive APIs using the remote_id value. Unfortunately, the direct download functionality via Pipedrive API (for files stored outside) is not available at the moment

Hello guys,

After researching so much I get to know that, if we want to download the files from pipedrive we have to get the first files from deal/files/ api.

Then we will get the url and name, which we have to pass to file_get_contents.

$fileId = 538697;

$downloadurl = “https://” . $company_domain . “.pipedrive.com/v1/files/$fileId /download?api_token=$apiToken”;
$file_name = ‘pipedrive_sample_data.xlsx’;

//save the file by using base name
if(file_put_contents( $file_name,file_get_contents($downloadurl))){
echo “File downloaded successfully!”;
}else{
echo “File downloading failed!”;
}