use LWP::UserAgent; use JSON::XS; our $browser = LWP::UserAgent->new(timeout => 30); my $url = 'https://api-ssl.bitly.com/v4/expand'; my $header = ['Authorization' => 'Bearer 1a2b3c4d5e']; # use a valid one instead of this made-up one my $data = {"bitlink_id" => 'bit.ly/361RdUL'}; # note domain is included my $encoded_data = encode_json($data); my $r = HTTP::Request->new('POST', $url, $header, $encoded_data); my $response = $browser->request($r); my $foo = 1; if ($response->is_success) { print $response->decoded_content; } else { die $response->status_line; }