0
當我運行我的Perl腳本時顯示錯誤。它說,內部服務器錯誤。錯誤代碼500.我該如何處理?如何處理HTTP Post錯誤
use warnings;
use strict;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $url = "https://myhost/test/server.php";
my $req = HTTP::Request->new(POST => $url);
$req->header('content-type' => 'application/json');
my $post_data = {"value": "sample", "value2":"sample2"};
$req->content($post_data);
#print $req->as_string;
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";
}