Postman example showing document upload

SOLVE
JBourdeau
Member

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

Accepted Solutions
dennisedson
Solution
Community Manager

@tjoyce , have any suggestions for @JBourdeau ?

Thanks,

Dennis



Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content

View solution in original post

tjoyce
Solution
Recognized Expert | Platinum Partner

Image 2021-06-14 at 11.17.43 AM.png

 

This should work with postman @JBourdeau 

View solution in original post

3 Replies 3
dennisedson
Solution
Community Manager

@tjoyce , have any suggestions for @JBourdeau ?

Thanks,

Dennis



Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content

View solution in original post

webdew
Top Contributor | Diamond Partner

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. 



tjoyce
Solution
Recognized Expert | Platinum Partner

Image 2021-06-14 at 11.17.43 AM.png

 

This should work with postman @JBourdeau 

View solution in original post