APIs & Integrations

JBourdeau
Membre

Postman example showing document upload

Résolue

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 Solutions acceptées
dennisedson
Solution
Équipe de développement de HubSpot
Équipe de développement de HubSpot

Postman example showing document upload

Résolue
tjoyce
Solution
Expert reconnu | Partenaire solutions Elite
Expert reconnu | Partenaire solutions Elite

Postman example showing document upload

Résolue

Image 2021-06-14 at 11.17.43 AM.png

 

This should work with postman @JBourdeau 

Voir la solution dans l'envoi d'origine

3 Réponses
tjoyce
Solution
Expert reconnu | Partenaire solutions Elite
Expert reconnu | Partenaire solutions Elite

Postman example showing document upload

Résolue

Image 2021-06-14 at 11.17.43 AM.png

 

This should work with postman @JBourdeau 

webdew
Guide | Partenaire solutions Diamond
Guide | Partenaire solutions Diamond

Postman example showing document upload

Résolue

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
Équipe de développement de HubSpot
Équipe de développement de HubSpot

Postman example showing document upload

Résolue

@tjoyce , have any suggestions for @JBourdeau ?