Reputation: 341
i'm using Perl to access a Rest-Api:
use LWP::UserAgent;
use HTTP::Request::Common;
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request::Common::PUT("http://xxx:yyy/...");
$req->header('content-type' => 'application/json');
$req->authorization_basic('abc','xyz');
my $put_data = '{
"description" : "TestPut"
}';
$req->content($put_data);
my $resp = $ua->request($req);
if ($resp->is_success){
print $resp->content() . "\n";
}
else{
print "PUT failed:\n";
print $resp->message . "\n";
}
But i am getting a "Method not allowed" Message. The GET works fine. Could this be a Problem by the Http-Server (Tomcat) or a firewall?
$req->as_string:
PUT #URL
Authorization: Basic xxx=
Content-Type: application/json
{
"description" : "TestPut"
}
Upvotes: 4
Views: 855
Reputation: 123270
The GET works fine. Could this be a Problem by the Http-Server (Tomcat) or a firewall?
Yes, you have to look there. GET and POST are the usual methods to access a web site while PUT is usually used for REST or WebDAV and not used by the web browser (unless you do your own XHR requests). Thus it might be that a firewall or HTTP server restricts access to this method.
Upvotes: 1