APIs & Integrations

JBourdeau
メンバー

Postman example showing document upload

解決

I need to upload a document to show developers how easy it is.  Is there an example showing how to upload a document using Postman?

I would be using :

https://api.hubapi.com//filemanager/api/v3/files/upload?hapikey=[api key]

 

What parameters would I pass in the body?  

The file will be in base64 format

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

Postman example showing document upload

解決
tjoyce
解決策
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

Postman example showing document upload

解決

Image 2021-06-14 at 11.17.43 AM.png

 

This should work with postman @JBourdeau 

元の投稿で解決策を見る

3件の返信
tjoyce
解決策
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

Postman example showing document upload

解決

Image 2021-06-14 at 11.17.43 AM.png

 

This should work with postman @JBourdeau 

webdew
ガイド役 | Diamond Partner
ガイド役 | Diamond Partner

Postman example showing document upload

解決

Hi @JBourdeau ,

$hapikey = 'demo';
$post_url = "https://api.hubapi.com/filemanager/api/v3/files/upload?hapikey=".$hapikey;

$upload_file = new \CURLFile('https://www.domain.com/images/test.jpeg','application/octet-stream');

$file_options = array(
"access" => "PUBLIC_INDEXABLE",
"ttl" => "P3M",
"overwrite" => false,
"duplicateValidationStrategy" => "NONE",
"duplicateValidationScope" => "ENTIRE_PORTAL"
);

$post_data = array(
"file" => $upload_file,
"options" => json_encode($file_options),
"folderPath" => "/"
);

$ch = curl_init();
@curl_setopt($ch, CURLOPT_POST, true);
@curl_setopt($ch, CURLOPT_URL, $post_url);
@curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);

$response = @curl_exec($ch); //Log the response from HubSpot as needed.
$status_code = @curl_getinfo($ch, CURLINFO_HTTP_CODE); //Log the response status code
@curl_close($ch);

$response = json_decode($response);
print_r($response);
die;


Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards. 



dennisedson
解決策
HubSpot製品開発チーム
HubSpot製品開発チーム

Postman example showing document upload

解決

@tjoyce , have any suggestions for @JBourdeau ?