我正在尝试向 Cisco ISE 发送 GET 请求,但收到此错误:
415 不支持的媒体类型
我究竟做错了什么?API 文档说:
方法:获取
URI:https ://10.10.10.10:9060/ers/config/networkdevice/
HTTP“接受”标头:application/vnd.com.cisco.ise.network.networkdevice.1.0+xml
所以,我应该能够以 XML 格式接收数据。
我已经尝试过这样做:
$header->header(
'Content-Type'=>'application/vnd.com.cisco.ise.network.networkdevice.xml');
$header->header(
'Content-Type'=>'application/vnd.com.cisco.ise.network.networkdevice.1.0+xml');
没有任何效果..每次我收到上述错误。
这是我的完整代码。
use strict;
use warnings;
use JSON -support_by_pp;
use LWP 5.64;
use LWP::UserAgent;
use MIME::Base64;
use REST::Client;
use IO::Socket::SSL;
use HTTP::Headers;
#So dass es auch ohne SSL Sertifizierung funktioniert
BEGIN { $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0 }
#Create a user agent object
my $ua = LWP::UserAgent->new(ssl_opts=> {
SSL_verify_mode => SSL_VERIFY_NONE(),
verify_hostname => 0,
}
);
#Create a request
my $uri='https://10.10.10.10:9060/ers/config/networkdevice';
my $header = HTTP::Headers->new;
$header->header('Content-Type'=>'application/vnd.com.cisco.ise.network.networkdevice');
my $req = HTTP::Request->new('GET', $uri, $header);
$req-> authorization_basic("user", "user");
#Pass request to the user agent and get a response back
my $res = $ua->request($req);
#Check the outcome of the response
if ($res->is_success) {
print $res->content;
} else {
print $res->status_line, "n";
}