Perl HTTP :: Request Put & # 8594; Method not allowed

I use Perl to access 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 get the message "Method not allowed". GET works great. Could this be a Http-Server (Tomcat) problem or a firewall?

$ req-> as_string:

 PUT #URL Authorization: Basic xxx= Content-Type: application/json { "description" : "TestPut" } 
+4
source share
1 answer

GET works great. Could this be a Http-Server (Tomcat) problem or a firewall?

Yes, you should look there. GET and POST are common methods of accessing a website, while PUT is usually used for REST or WebDAV and is not used by a web browser (unless you are making your own XHR requests). Thus, it is possible that a firewall or HTTP server restricts access to this method.

+1
source

All Articles