Perl Http Request

[Solved] Perl Http Request | Perl - Code Explorer | yomemimo.com
Question : perl http request

Answered by : little-heron-q3nbcrbvm1lf

#!/usr/bin/env perl 
use strict;
use warnings; 
use Encode qw(encode_utf8);
use HTTP::Request ();
use JSON::MaybeXS qw(encode_json);
my $url = 'https://www.example.com/api/user/123';
my $header = ['Content-Type' => 'application/json; charset=UTF-8'];
my $data = {foo => 'bar', baz => 'quux'};
my $encoded_data = encode_utf8(encode_json($data));
my $r = HTTP::Request->new('POST', $url, $header, $encoded_data);
# at this point, we could send it via LWP::UserAgent
# my $ua = LWP::UserAgent->new();
# my $res = $ua->request($r);

Source : | Last Update : Tue, 08 Oct 19

Question : perl http request

Answered by : little-heron-q3nbcrbvm1lf

#!/usr/bin/env perl use strict;use warnings; use Encode qw(encode_utf8);use HTTP::Request ();use JSON::MaybeXS qw(encode_json); my $url = 'https://www.example.com/api/user/123';my $header = ['Content-Type' => 'application/json; charset=UTF-8'];my $data = {foo => 'bar', baz => 'quux'};my $encoded_data = encode_utf8(encode_json($data)); my $r = HTTP::Request->new('POST', $url, $header, $encoded_data);# at this point, we could send it via LWP::UserAgent# my $ua = LWP::UserAgent->new();# my $res = $ua->request($r);

Source : | Last Update : Tue, 08 Oct 19

Answers related to perl http request

Code Explorer Popular Question For Perl