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
@tjoyce , have any suggestions for @JBourdeau ?
system
3
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
4
This should work with postman @JBourdeau