How to download deal files to particular folder

I want to download deal files to particular folder, but when I try to download file using this url in php code.

https://" . $company_domain . ".pipedrive.com/api/v1/files/1344/download?api_token=$apiToken

I am getting the unauthorized access issue.

Can anyone let me know how to do that, I have given the permission to the deal as well, but still getting issue.

Hi 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.

$downloadurl = “https://” . $company_domain . “.pipedrive.com/v1/files/538697/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!”;
}