http://qs1969.pair.com?node_id=1154961

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks!

I am trying to send text files ( using only one file here ) to a site's directory "https://www.tothesite.com/place/44498/", using POST.
I am getting a 404 error, but the url is correct. I think my problem is with the Perl, am I using the right way to use POST to send a file through HTTPS, any suggestion?
#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use Data::Dumper; my $ua = LWP::UserAgent->new(); my $server_endpoint = "https://www.tothesite.com/place/44498/"; # set custom HTTP request header fields my $req = HTTP::Request->new(POST => $server_endpoint); $req->headers(); print Dumper( $req->headers() ); $req->header('x-auth-token' => 'Token e45ttkfksj48sdfj4jd9abcdd'); # add POST data to HTTP request body my $filename = "/var/www/location/first_text.txt"; $req->content($filename); my $resp = $ua->request($req); if ($resp->is_success) { my $message = $resp->decoded_content; print "Received reply: $message\n"; }else { print "HTTP POST error code: ", $resp->code, "\n"; print "HTTP POST error message: ", $resp->message, "\n"; }

Thanks for looking!