APIs & Integrations

ArturMudrytsky
Member

Uploading files by API to the file manager

Hi. I'm having difficulty with uploading files using the API. I keep getting an error 400 "Bad Request", which doesn't give any more info about what's wrong.

 

I've read the documentation here:

https://developers.hubspot.com/docs/methods/files/post_files

 

 

The trouble is that these all explain how to do it with particular languages, such as Python. I'm using perl.

 

my $ua = LWP::UserAgent->new();
my $request = HTTP::Request->new();
$request->uri( $location );

$request->method('POST');
my %Hash;
%Hash = (
data => {
'folder_paths' => '/138263',
},
files => {
files => $fh
}
);
$request->content(%Hash);
 
 
I've tried many other permutations too. 
0 Upvotes
1 Reply 1
WendyGoh
HubSpot Employee
HubSpot Employee

Uploading files by API to the file manager

Hey @ArturMudrytsky ,

 

While I'm not too familar with perl, I'm guessing that could it be because of the single quotation?

 

So instead of:

 

'folder_paths' => '/138263',
 
can you try:
 
"folder_paths" => "/138263",
 
and see if it works?
0 Upvotes