Search
 
SCRIPT & CODE EXAMPLE
 

PERL

perl http request

#!/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);
Comment

perl http request

#!/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);
Comment

PREVIOUS NEXT
Code Example
Perl :: perl rename a file 
Perl :: Perl (perl 2018.12) sample 
Pascal :: store input in variable in pascal 
Pascal :: pascal readln() 
Pascal :: delay() in Pascal 
Pascal :: array pascal 
Pascal :: pascal const 
Powershell :: powershell remove node_modules 
Powershell :: ps where-object 
Gdscript :: godot 
Clojure :: toggle button clojure 
Lisp :: print lisp 
Assembly :: docker cannot stop container 
Assembly :: django template url with parameter 
Assembly :: visual studio change assembly name 
Assembly :: discord.py change status to invisible 
Javascript :: jquery vslidation remove spaces from input 
Javascript :: map range of numbers to another range 
Javascript :: jest cache clear 
Javascript :: javascript replace spaces with dashes 
Javascript :: import redux thunk 
Javascript :: jquery refresh page 
Javascript :: delete session javascript 
Javascript :: get week day name in javascript 
Javascript :: how to remove checked attribute of checkbox in jquery 
Javascript :: loop array backwards javascript 
Javascript :: generate random whole numbers within a range javascript 
Javascript :: jquery remove and add class 
Javascript :: how to use another port in angular 
Javascript :: How to get current URL with Javascript or React 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =