我发送POST请求思科ISE使用XML数据和我收到以下错误:400对XML POST请求无效
400 Bad Request
我已经检查了我的XML文本,标题和认证数据的RESTClient实现(对于REST风格的Web服务),它成功发布了Post请求。但是,我的要求与其预期的客户端一致,我相信我的脚本有问题。
Method: POST
URI: https://10.10.10.10:9060/ers/config/networkdevice
HTTP 'Content-Type' header:application/vnd.com.cisco.ise.network.networkdevice.1.0+xml; charset=utf-8
HTTP 'Accept' header: application/vnd.com.cisco.ise.network.networkdevice.1.0+xml
SMB能告诉我这是不对我的XML数据:
,我应该有以下的API文档的状态?或者这个错误是什么意思?
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;
use HTTP::Request;
use XML::Simple;
#Create a user agent object
my $ua = LWP::UserAgent->new(ssl_opts=> {
SSL_verify_mode => SSL_VERIFY_NONE(),
verify_hostname => 0,
}
);
my $uri='https://10.10.10.10:9060/ers/config/networkdevice/';
my $header = HTTP::Headers->new;
my $req = HTTP::Request->new('POST', $uri);
my $message =('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns3:networkdevice name="LAB-WLZZ" id="89c7e480-591f-11e4-ac6a b83861d71000" xmlns:ns2="ers.ise.cisco.com" xmlns:ns3="network.ers.ise.cisco.com">
<authenticationSettings>
<enableKeyWrap>false</enableKeyWrap>
<keyInputFormat>ASCII</keyInputFormat>
<networkProtocol>RADIUS</networkProtocol>
<radiusSharedSecret>******</radiusSharedSecret>
</authenticationSettings>
<NetworkDeviceIPList>
<NetworkDeviceIP>
<ipaddress>9.9.9.9</ipaddress>
<mask>21</mask>
</NetworkDeviceIP>
</NetworkDeviceIPList>
<NetworkDeviceGroupList>
<NetworkDeviceGroup>Location</NetworkDeviceGroup>
<NetworkDeviceGroup>DeviceType</NetworkDeviceGroup>
</NetworkDeviceGroupList>
</ns3:networkdevice>')
;
$req->header('Accept'=>'application/vnd.com.cisco.ise.network.networkdevice.1.0+xml');
$req->header('Content-Type'=>'application/vnd.com.cisco.ise.network.networkdevice.1.0+xml');
$req->content($message);
$req->content_type("charset=utf-8");
$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->status_line, "n";
} else {
print $res->status_line, "n";
}
你实际上并没有使用REST ::客户,即使你'使用REST ::客户端;'。你为什么不在'my $ client = REST :: Client-> new(...)'? – ThisSuitIsBlackNot
什么服务器消息块(SMB)有这个做什么? – Borodin