cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1305
Views
0
Helpful
0
Replies

Cisco ISE 400 Bad Request on XML POST

o.akymenko
Level 1
Level 1

I'm sending a Post request to CISCO ISE with XML data and I receive the following error:

400 Bad Request

I have checked my XML text, headers and authentication data in the RestClient (for RESTful web Services), it successfully makes the Post request. However, my request is failing with it's intended client and I believe there is something wrong with my script.

The API Documentation states that I should have the following:

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

Can smb tell me that is wrong with my XML data? Or what does this errow say?

 use strict;
 use warnings;
 use JSON -support_by_pp;
 use LWP 5.64;
 use LWP::UserAgent;
 use MIME::Base64;
 use IO::Socket::SSL;
 use HTTP::Headers;
 use HTTP::Request;

 #Create a user agent object
 my $ua = LWP::UserAgent->new(ssl_opts=> {
  SSL_verify_mode => SSL_VERIFY_NONE(),
  verify_hostname => 0,
  }
 );

my $message ='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  <ns3:networkdevice name="LAB-ZZZZ" id="89c7e480-591f-11e4-ac6a-b83861d71111" description="example nd"  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>11.12.13.14</ipaddress>
          <mask>21</mask>
        </NetworkDeviceIP>
      </NetworkDeviceIPList>
      <NetworkDeviceGroupList>
        <NetworkDeviceGroup>Location</NetworkDeviceGroup>
        <NetworkDeviceGroup>Device Type</NetworkDeviceGroup>
      </NetworkDeviceGroupList>
   </ns3:networkdevice>'
;

my $uri='https://10.0.0.0:9060/ers/config/networkdevice';
   my $req = HTTP::Request->new('POST', $uri,
[Accept=>'application/vnd.com.cisco.ise.network.networkdevice.1.1+xml',
      Content_Type=>'application/vnd.com.cisco.ise.network.networkdevice.1.1+xml;charset=utf-8'], $message);

$req->content($message);
 $req->authorization_basic("user", "password");
 
  #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";
         }
0 Replies 0