cormanaz has asked for the wisdom of the Perl Monks concerning the following question:
Neither does $header = ['Authorization' => 'Bearer 1a2b3c4d']; or $header = ['Authorization' => 'Bearer {1a2b3c4d}'];use LWP::UserAgent; use JSON::XS; my $browser = LWP::UserAgent->new(timeout => 30); my $url = 'https://api-ssl.bitly.com/v4/expand'; my $header = ['Authorization' => '1a2b3c4d5e']; # not my real access t +oken my $data = {"bitlink_id" => 'ze6poY'}; 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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to format HTTP::Request for bit.ly api expand endpoint
by Corion (Patriarch) on May 22, 2020 at 17:23 UTC | |
by cormanaz (Deacon) on May 22, 2020 at 19:02 UTC | |
by perlfan (Parson) on May 23, 2020 at 18:27 UTC |