APIs & Integrations

PNie
メンバー | Platinum Partner
メンバー | Platinum Partner

Files API Overwrite not behaving

解決

Using
/files/v3/files/import-from-url/async

to pull an external file into hubspot files. This appears to work. However when the overwrite option is set to true, it doesn't overwrite, just end up with a folder with 
test
test-1
test-2
test-3
test-4

Then for some reason, consistently after -4 it changes to test-datetime stamp
test-Dec-06-2021-02-39-17-81-AM


Just running the below (where XXX = api key, file url, folderid)

 

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.hubapi.com/files/v3/files/import-from-url/async?hapikey=XXX',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "access":"PUBLIC_NOT_INDEXABLE",
    "name":"test",
    "url":"XXX",
    "duplicateValidationStrategy":"NONE",
    "duplicateValidationScope":"EXACT_FOLDER",
    "overwrite":true,
    "folderId":"XXX"
}',
  CURLOPT_HTTPHEADER => array(
    'accept: application/json',
    'content-type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);

 

 
Just wanting it to overwrite anyone able to replicate the issue or able to point me in the right direction.

0 いいね!
1件の承認済みベストアンサー
dennisedson
解決策
HubSpot製品開発チーム
HubSpot製品開発チーム

Files API Overwrite not behaving

解決

@blend-thomas ,

Believe it or not, I received a message on Friday that this was resolved!  feel free to yell at me if it is still not working.

元の投稿で解決策を見る

11件の返信
blend-thomas
投稿者 | Diamond Partner
投稿者 | Diamond Partner

Files API Overwrite not behaving

解決

Any update on this one please @dennisedson ?

0 いいね!
dennisedson
解決策
HubSpot製品開発チーム
HubSpot製品開発チーム

Files API Overwrite not behaving

解決

@blend-thomas ,

Believe it or not, I received a message on Friday that this was resolved!  feel free to yell at me if it is still not working.

lstepany
投稿者 | Elite Partner
投稿者 | Elite Partner

Files API Overwrite not behaving

解決

There are 2 API endpoint and the one that I use is defenitly not working ((

0 いいね!
lstepany
投稿者 | Elite Partner
投稿者 | Elite Partner

Files API Overwrite not behaving

解決

I have the same issue. Both API endpoints for overwritting and replacing the file just don't work ((

 

0 いいね!
ghostcat
メンバー

Files API Overwrite not behaving

解決

Hi, i'm having a similar issue. I'm using 

 

/files/v3/files/import-from-url/async

 

in a serverless function to write a json file to a folder. Here's my code:

 

const axios = require('axios');
exports.main = async (context, sendResponse) => {
  const response = await axios.post(
      'https://api.hubapi.com/files/v3/files/import-from-url/async',
      {
          'access': 'PUBLIC_INDEXABLE',
          'name': 'MY_FILENAME.json',
          'url': 'MY_JSON_URL_TO_IMPORT',
          'folderPath': 'MY_FOLDER',
          'duplicateValidationStrategy': 'NONE',
          'duplicateValidationScope': 'ENTIRE_PORTAL',
          'overwrite': true
      },
      {
          headers: {
              'authorization': 'Bearer MY_TOKEN',
              'content-type': 'application/json'
          }
      }
  );
  sendResponse({body: JSON.stringify(response.data), statusCode: 200});
};

 


The first time, it works fine. MY_FILENAME.json file is put in the folder, no problem. The second time I run it, Instead of overwriting the file, a new file is added to the folder with an extra .json extension added (e.g.MY_FILENAME.json.json). Any subsequent API calls will overwrite the MY_FILENAME.json.json file, but leaves the original MY_FILENAME.json file unchanged. Any help?

0 いいね!
blend-thomas
投稿者 | Diamond Partner
投稿者 | Diamond Partner

Files API Overwrite not behaving

解決

Oh yes... Seems to working! Fantastic! 👍

MDeladi
メンバー

Files API Overwrite not behaving

解決

Hello!

 

Just checking to see if anyone found a resolution to this. I am running into the same issue.

 

Thanks!

0 いいね!
LCantos
メンバー

Files API Overwrite not behaving

解決

Any news on this issue? I'm still having issues with the overwrite option. 

Thank you,

0 いいね!
blend-thomas
投稿者 | Diamond Partner
投稿者 | Diamond Partner

Files API Overwrite not behaving

解決

This issue is blocking me too 😞

0 いいね!
RMones
投稿者 | Platinum Partner
投稿者 | Platinum Partner

Files API Overwrite not behaving

解決

Hi @PNie ,

 

I can reproduce it, and have the same behaviour.

It looks that the parameter overwrite is not accepted or ignored by the async API. 


I found the following information

 

 

Overwrite:
If true this file with replace any existing files with the name name, folder, and type.

Note: If this is set to false, and the uploaded file matches the filename of an existing file in the same folder, the file will be uploaded with a number incremented filename (e.g. example_file.txt will become example_file-1.txt)

 

 

https://legacydocs.hubspot.com/docs/methods/files/v3/upload_new_file

 

 

I tried is also with the synchronious endpoint, and that one is accepting the overwrite parameter and is updating the file with overwrite. (https://api.hubapi.com/filemanager/api/v3/files/upload?hapikey=xxx)

 

Maybe @dennisedson can tell us if this function isn't implemented in the async API? 

 

Regards Ronald

dennisedson
HubSpot製品開発チーム
HubSpot製品開発チーム

Files API Overwrite not behaving

解決

Will look into this 🤔

0 いいね!