#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use JSON; use FindBin qw($Bin);; my $token = ''; my $url = 'http://'; my $attributes = encode_json ({ name => "test.txt", parent => { id => 0 } }); my $ua = LWP::UserAgent->new; my $response = $ua->post($url, Content_Type => 'form-data', Authorization => "Bearer $token", Content => [ attributes => $attributes, file => [ "$Bin/test.txt" ], ], ); if ($response->is_success) { print $response->decoded_content; } else { die $response->status_line; }