APIs & Integrations

JBourdeau
Member

Postman example showing document upload

SOLVE

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 Accepted solutions
dennisedson
Solution
HubSpot Product Team
HubSpot Product Team

Postman example showing document upload

SOLVE

@tjoyce , have any suggestions for @JBourdeau ?

View solution in original post

tjoyce
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Postman example showing document upload

SOLVE

Image 2021-06-14 at 11.17.43 AM.png

 

This should work with postman @JBourdeau 

View solution in original post

3 Replies 3
tjoyce
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Postman example showing document upload

SOLVE

Image 2021-06-14 at 11.17.43 AM.png

 

This should work with postman @JBourdeau 

webdew
Guide | Diamond Partner
Guide | Diamond Partner

Postman example showing document upload

SOLVE

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
Solution
HubSpot Product Team
HubSpot Product Team

Postman example showing document upload

SOLVE

@tjoyce , have any suggestions for @JBourdeau ?