Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use LWP::UserAgent;
- my $ua = LWP::UserAgent->new;
- # set custom HTTP request header fields
- my $req = HTTP::Request->new(PUT => "https://thesite.com");
- $req->header('Authorization' => 'myauth');
- $req->header('Accept' => 'JSON:Application/JSON');
- $req->header('Content-Type' => 'JSON:Application/JSON');
- $req->header('Host' => 'api.thesite.com');
- $req->content('Text' => 'thetext');
- my $resp = $ua->request($req);
- if ($resp->is_success) {
- my $message = $resp->decoded_content;
- print "Received reply: $messagen";
- }
- else {
- print "HTTP POST error code: ", $resp->code, "n";
- print "HTTP POST error message: ", $resp->message, "n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement