Is there any way to download all files attached to deals and persons in PD , i tried to call API of GET Files , but i got links , i want to auto download all files , please advice.
Bassel,
I am doing something similar. You will need to do the following:
- Fetch all of the Files using https://api.pipedrive.com/v1/files?api_token=API_KEY, where API_KEY is the API key for the Pipedrive account you want to access.
- For each of the results returned, get the file ID
- Fetch the contents of the file using https://api.pipedrive.com/v1/file/ID/download?api_token=API_KEY, where ID is the id of the file.
Note that the second call to file/ID/download actually redirects the fetch to an Amazon s3 file, which has several negative effects:
- You can not call this from a browser, it will violate CORS rules.
- It will return the raw file (bytes) only, so you will need to read the results into a byte array to deal with it
I have some sample Javascript code I can share with you if you want.
John
1 Like
John,
THank your for your response , please share teh js code with me.
BR,
Bassel
fetch('https://api.pipedrive.com/v1/files?api_token=APIKEY', {
method: 'GET',
headers: {"Accept": "application/json"},
mode: 'cors',
redirect: "follow"
})
.json()
.then(result => {
const files = results.data;
for(let i = 0; i < files.length; i++) {
const file = files[i];
fetch(`https://api.pipedrive.com/v1/files/${file.id}/download?api_token=APIKEY`, {
method: 'GET',
mode: 'cors',
redirect: "follow"
});
.then(file => {
// This will be raw data (bytearray)
}
}
});