我發送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