<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Cisco ISE 3.1 RESTful API - HTTP PUT for updating NADs is not work in Network Access Control</title>
    <link>https://community.cisco.com/t5/network-access-control/cisco-ise-3-1-restful-api-http-put-for-updating-nads-is-not/m-p/4696338#M577491</link>
    <description>&lt;P&gt;Many, many thanks for this discussion! I was struggling hours on the same problem.&amp;nbsp; Below my python code for a really old ISE version 2.2.0.470 (with patches 2,4,5,9,13). Hopefully it will be useful for other people:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;#!/usr/bin/env python3

import requests
from urllib3.exceptions import InsecureRequestWarning
import json
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)

url = "https://x.x.x.x:9060/ers/config/networkdevice"


header = {'accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Basic ZXJzLXVzcjI6UGFzc3dvcmQxMjM0',
'Cache-Control': 'no-cache'}

username = 'ers-usr2'
password = 'Password1234'

payload = {
"NetworkDevice": {
"id": "5678",
"name": "TEST-DEVICE2",
"authenticationSettings": {
"networkProtocol": "RADIUS",
"radiusSharedSecret": "cisco1234",
"enableKeyWrap": False,
"keyInputFormat": "ASCII"
},
"tacacsSettings": {
"sharedSecret": "Cisco1234",
"connectModeOptions": "OFF",
"previousSharedSecret": "test123",
"previousSharedSecretExpiry": 0
},
"profileName": "Cisco",
"coaPort": 1700,
"NetworkDeviceIPList": [{
"ipaddress": "192.168.4.5",
"mask": 32
}],
"NetworkDeviceGroupList": ["Device Type#All Device Types#IPC#SWITCH#SLAN", "IPSEC#Is IPSEC Device#No", "Location#All Locations"]
}
}

response = requests.post(url, proxies={'http': None, 'https': None}, data=json.dumps(payload), auth=requests.auth.HTTPBasicAuth(username, password), headers=header, verify=False)
print(response)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Sep 2022 21:28:21 GMT</pubDate>
    <dc:creator>a.mitsova</dc:creator>
    <dc:date>2022-09-30T21:28:21Z</dc:date>
    <item>
      <title>Cisco ISE 3.1 RESTful API - HTTP PUT for updating NADs is not working</title>
      <link>https://community.cisco.com/t5/network-access-control/cisco-ise-3-1-restful-api-http-put-for-updating-nads-is-not/m-p/4571714#M573505</link>
      <description>&lt;P&gt;Hello community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working on creating an automated way to manage NADs on Cisco ISE via RESTful API in Python.&lt;/P&gt;&lt;P&gt;I'm relying on the requests library, but unfortunately when I try to use the PUT operation to update NAD with new information, I receive a status code of 400 with the following error code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
  "ERSResponse" : {
    "operation" : "PUT-update by name-networkdevice",
    "messages" : [ {
      "title" : "Resource Initialization Failed: Invalid JSON: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token\n ",
      "type" : "ERROR",
      "code" : "Application resource validation exception"
    } ],
    "link" : {
      "rel" : "related",
      "href" : "https://192.168.100.100:9060/ers/config/networkdevice/name/TEST",
      "type" : "application/xml"
    }
  }
}&lt;/PRE&gt;&lt;P&gt;I didn't see this error message before and I was also unable to find any other reference to this, so I'm relying on you, experts, to help me figure this one out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using ISE VM version&amp;nbsp;&lt;SPAN&gt;3.1.0.518 running in eve-ng emulator for testing the solution.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the relevant piece of code that I use to make the PUT operation:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;url = f"{self.url_base}/config/networkdevice"
nad_url = requests.put(f"{url}/name/{nad_name}", headers=self.headers, auth=self.auth, data=json.dumps(payload, indent=2), verify=False)&lt;/PRE&gt;&lt;P&gt;The "payload" variable holds the actual content in JSON format for updating the NAD that I've already verified through&amp;nbsp;&lt;A href="https://jsonformatter.curiousconcept.com/#" target="_blank" rel="noopener"&gt;https://jsonformatter.curiousconcept.com/#&lt;/A&gt;&amp;nbsp;as valid.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For a reference, I obtained the output of how the payload actually looks like after Python processes my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
  "NetworkDevice": {
    "id": "65afd750-a4a3-11ec-aa9f-e2a4bd57a766",
    "name": "TEST",
    "description": "test123",
    "authenticationSettings": {
      "networkProtocol": "RADIUS",
      "radiusSharedSecret": "Test132*",
      "enableKeyWrap": false,
      "dtlsRequired": false,
      "keyEncryptionKey": "",
      "messageAuthenticatorCodeKey": "",
      "keyInputFormat": "ASCII",
      "enableMultiSecret": false
    },
    "tacacsSettings": {
      "sharedSecret": "Test124",
      "connectModeOptions": "ON_LEGACY",
      "previousSharedSecret": "",
      "previousSharedSecretExpiry": ""
    },
    "profileName": "Cisco",
    "coaPort": 1700,
    "link": {
      "rel": "self",
      "href": "https://192.168.100.100:9060/ers/config/networkdevice/name/TEST",
      "type": "application/json"
    },
    "NetworkDeviceIPList": {
      "ipaddress": "1.1.1.2",
      "mask": 32
    },
    "NetworkDeviceGroupList": [
      "Device Type#All Device Types",
      "IPSEC#Is IPSEC Device#No",
      "Location#All Locations"
    ]
  }
}&lt;/PRE&gt;&lt;P&gt;I've already tried some other HTTP operations with the requests package, such as GET and DELETE. Both of them are working beautifully, so I assume I must be making some mistake in specifying the payload structure for the PUT operation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To build the JSON structure, I followed&amp;nbsp;&lt;A href="https://developer.cisco.com/docs/identity-services-engine/v1/#!networkdevice" target="_blank" rel="noopener"&gt;https://developer.cisco.com/docs/identity-services-engine/v1/#!networkdevice&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help/advise would be much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tomas&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 14:42:13 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-access-control/cisco-ise-3-1-restful-api-http-put-for-updating-nads-is-not/m-p/4571714#M573505</guid>
      <dc:creator>tomas.chyla02@gmail.com</dc:creator>
      <dc:date>2022-03-16T14:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Cisco ISE 3.1 RESTful API - HTTP PUT for updating NADs is not work</title>
      <link>https://community.cisco.com/t5/network-access-control/cisco-ise-3-1-restful-api-http-put-for-updating-nads-is-not/m-p/4571857#M573509</link>
      <description>&lt;P&gt;It seems that your json payload my be missing some required strings.&amp;nbsp; Here is an example of a payload used when updating an existing NAD via API.&amp;nbsp; Note that this was used with older versions of ISE.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;API_DATA = {&lt;BR /&gt;    "NetworkDevice": {&lt;BR /&gt;        "id": temp2,&lt;BR /&gt;        "name": "zzyy" + NAD_NAME,&lt;BR /&gt;        "profileName": "Cisco",&lt;BR /&gt;        "coaPort": "1700",&lt;BR /&gt;&lt;BR /&gt;    "authenticationSettings" : {&lt;BR /&gt;},&lt;BR /&gt;    "snmpsettings" : {&lt;BR /&gt;        "pollingInterval" : 3600,&lt;BR /&gt;        "linkTrapQuery" : "false",&lt;BR /&gt;        "macTrapQuery" : "false",&lt;BR /&gt;},&lt;BR /&gt;    "trustsecsettings" : {&lt;BR /&gt;        "deviceAuthenticationSettings" : {&lt;BR /&gt;},&lt;BR /&gt;        "sgaNotificationAndUpdates" : {&lt;BR /&gt;            "downlaodEnvironmentDataEveryXSeconds" : 86400,&lt;BR /&gt;            "downlaodPeerAuthorizationPolicyEveryXSeconds" : 86400,&lt;BR /&gt;            "reAuthenticationEveryXSeconds" : 86400,&lt;BR /&gt;            "downloadSGACLListsEveryXSeconds" : 86400,&lt;BR /&gt;            "otherSGADevicesToTrustThisDevice" : "true",&lt;BR /&gt;            "sendConfigurationToDevice" : "true",&lt;BR /&gt;            "sendConfigurationToDeviceUsing" : "ENABLE_USING_COA",&lt;BR /&gt;            "coaSourceHost" : "abcdefg"&lt;BR /&gt;},&lt;BR /&gt;    "deviceConfigurationDeployment" : {&lt;BR /&gt;        "includeWhenDeployingSGTUpdates" : "true", &lt;BR /&gt;    }&lt;BR /&gt;},&lt;BR /&gt;    "NetworkDeviceIPList": [&lt;BR /&gt;{&lt;BR /&gt;        "ipaddress": IP_ADDR,&lt;BR /&gt;        "mask": 32,&lt;BR /&gt;    }&lt;BR /&gt;],&lt;BR /&gt;    "NetworkDeviceGroupList": [&lt;BR /&gt;        "Location#All Locations#" + LOC,&lt;BR /&gt;        "Device Type#All Device Types#ZZZZ#" + OWNER,&lt;BR /&gt;        "IPSEC#Is IPSEC Device#No",&lt;BR /&gt;        ]&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;API_DEVICE = "https://&amp;lt;isepan&amp;gt;:9060/ers/config/networkdevice/" + temp2 &lt;BR /&gt;API_ERS_USER = "user","password"&lt;BR /&gt;r = requests.put(url=API_DEVICE, auth=API_ERS_USER, json=API_DATA, verify=True) &lt;/PRE&gt;
&lt;P&gt;Note that there are some variables referenced that will have to be modified to meet your needs, but hopefully this helps you troubleshoot further.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 17:15:31 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-access-control/cisco-ise-3-1-restful-api-http-put-for-updating-nads-is-not/m-p/4571857#M573509</guid>
      <dc:creator>Mike.Cifelli</dc:creator>
      <dc:date>2022-03-16T17:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: Cisco ISE 3.1 RESTful API - HTTP PUT for updating NADs is not work</title>
      <link>https://community.cisco.com/t5/network-access-control/cisco-ise-3-1-restful-api-http-put-for-updating-nads-is-not/m-p/4571900#M573511</link>
      <description>&lt;P&gt;Thanks Mike, that's a great advise.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I went through the documentation again and indeed I missed a few required items.&amp;nbsp;&lt;/P&gt;&lt;P&gt;After filling in all the missing required parts, it seems I finally managed to move forward, although the issue is still not resolved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I'm now getting stuck with the "enabled" boolean that is, according to the documentation, required to be specified under "authenticationSettings" list.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If I don't specify it, the error message I get is exactly the same.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I specify it, it returns a different error with the same status code of 400:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
  "ERSResponse" : {
    "operation" : "PUT-update by name-networkdevice",
    "messages" : [ {
      "title" : "Resource Initialization Failed: Invalid JSON: Unrecognized field \"enabled\" (Class network.AuthenticationSettings), not marked as ignorable\n ",
      "type" : "ERROR",
      "code" : "Application resource validation exception"
    } ],
    "link" : {
      "rel" : "related",
      "href" : "https://192.168.100.100:9060/ers/config/networkdevice/name/TEST",
      "type" : "application/xml"
    }
  }
}&lt;/PRE&gt;&lt;P&gt;This is the current content of the payload after update:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
  "NetworkDevice": {
    "id": "65afd750-a4a3-11ec-aa9f-e2a4bd57a766",
    "name": "TEST",
    "description": "test123",
    "profileName": "Cisco",
    "coaPort": 1700,
    "modelName": "C4701",
    "softwareVersion": "16.2.3(S)1",
    "authenticationSettings": {
      "radiusSharedSecret": "Test132*",
      "enableKeyWrap": false,
      "keyEncryptionKey": "",
      "keyInputFormat": "ASCII",
      "enabled": true
    },
    "tacacsSettings": {
      "sharedSecret": "Test124"
    },
    "link": {
      "rel": "self",
      "href": "https://192.168.100.100:9060/ers/config/networkdevice/name/TEST",
      "type": "application/json"
    },
    "NetworkDeviceIPList": {
      "ipaddress": "1.1.1.2",
      "mask": 32,
      "getIpaddressExclude": ""
    },
    "NetworkDeviceGroupList": [
      "Device Type#All Device Types",
      "IPSEC#Is IPSEC Device#No",
      "Location#All Locations"
    ],
    "snmpsettings": {
      "linkTrapQuery": false,
      "macTrapQuery": false,
      "originatingPolicyServicesNode": "Auto",
      "pollingInterval": 28800
    },
    "trustsecsettings": {
      "deviceAuthenticationSettings": {},
      "deviceConfigurationDeployment": {},
      "sgaNotificationAndUpdates": {}
    }
  }
}&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Mar 2022 18:06:59 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-access-control/cisco-ise-3-1-restful-api-http-put-for-updating-nads-is-not/m-p/4571900#M573511</guid>
      <dc:creator>tomas.chyla02@gmail.com</dc:creator>
      <dc:date>2022-03-16T18:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: Cisco ISE 3.1 RESTful API - HTTP PUT for updating NADs is not work</title>
      <link>https://community.cisco.com/t5/network-access-control/cisco-ise-3-1-restful-api-http-put-for-updating-nads-is-not/m-p/4571932#M573513</link>
      <description>&lt;P&gt;It is not clear what exactly you are changing with the PUT.&lt;/P&gt;
&lt;P&gt;Perform a GET on the specific network device you want to change.&lt;/P&gt;
&lt;P&gt;Take that JSON output and compare to what you are trying to PUT.&lt;/P&gt;
&lt;P&gt;The problem lies in that diff.&lt;/P&gt;
&lt;P&gt;The only thing you do &lt;EM&gt;not&lt;/EM&gt; need to include is &lt;/P&gt;
&lt;PRE&gt;    "link": {
      "rel": "self",
      "href": "https://192.168.100.100:9060/ers/config/networkdevice/name/TEST",
      "type": "application/json"
    },&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Anything that you leave out will be deleted. &lt;/P&gt;
&lt;P&gt;ISE does not yet have a PATCH capability so you must include everything else you want in the resource.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 18:46:05 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-access-control/cisco-ise-3-1-restful-api-http-put-for-updating-nads-is-not/m-p/4571932#M573513</guid>
      <dc:creator>thomas</dc:creator>
      <dc:date>2022-03-16T18:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: Cisco ISE 3.1 RESTful API - HTTP PUT for updating NADs is not work</title>
      <link>https://community.cisco.com/t5/network-access-control/cisco-ise-3-1-restful-api-http-put-for-updating-nads-is-not/m-p/4571948#M573514</link>
      <description>&lt;P&gt;Thank you Thomas.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Issue has been resolved. I forgot to wrap the "NetworkDeviceGroupList" in a list, therefore it was screaming at me the invalid JSON format error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For other people's reference I'm including a sample payload that is working on the latest ISE version 3.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
  "NetworkDevice": {
    "id": "65afd750-a4a3-11ec-aa9f-e2a4bd57a766",
    "name": "TEST",
    "description": "test123",
    "profileName": "Cisco",
    "coaPort": 1700,
    "modelName": "C4701",
    "softwareVersion": "16.2.3(S)1",
    "authenticationSettings": {
      "networkProtocol": "RADIUS",
      "radiusSharedSecret": "Test132*",
      "enableKeyWrap": false,
      "dtlsRequired": false,
      "keyEncryptionKey": "",
      "keyInputFormat": "ASCII",
      "messageAuthenticatorCodeKey": "",
      "enableMultiSecret": "false"
    },
    "tacacsSettings": {
      "sharedSecret": "Test124",
      "connectModeOptions": "ON_LEGACY",
      "previousSharedSecret": "test123",
      "previousSharedSecretExpiry": 0
    },
    "NetworkDeviceIPList": [
      {
        "ipaddress": "1.1.1.2",
        "mask": 32
      }
    ],
    "NetworkDeviceGroupList": [
      "Device Type#All Device Types",
      "IPSEC#Is IPSEC Device#No",
      "Location#All Locations"
    ],
    "snmpsettings": {
      "linkTrapQuery": false,
      "macTrapQuery": false,
      "originatingPolicyServicesNode": "Auto",
      "pollingInterval": 28800
    },
    "trustsecsettings": {
      "deviceAuthenticationSettings": {},
      "deviceConfigurationDeployment": {},
      "sgaNotificationAndUpdates": {}
    }
  }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 19:03:00 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-access-control/cisco-ise-3-1-restful-api-http-put-for-updating-nads-is-not/m-p/4571948#M573514</guid>
      <dc:creator>tomas.chyla02@gmail.com</dc:creator>
      <dc:date>2022-03-16T19:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Cisco ISE 3.1 RESTful API - HTTP PUT for updating NADs is not work</title>
      <link>https://community.cisco.com/t5/network-access-control/cisco-ise-3-1-restful-api-http-put-for-updating-nads-is-not/m-p/4696338#M577491</link>
      <description>&lt;P&gt;Many, many thanks for this discussion! I was struggling hours on the same problem.&amp;nbsp; Below my python code for a really old ISE version 2.2.0.470 (with patches 2,4,5,9,13). Hopefully it will be useful for other people:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;#!/usr/bin/env python3

import requests
from urllib3.exceptions import InsecureRequestWarning
import json
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)

url = "https://x.x.x.x:9060/ers/config/networkdevice"


header = {'accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Basic ZXJzLXVzcjI6UGFzc3dvcmQxMjM0',
'Cache-Control': 'no-cache'}

username = 'ers-usr2'
password = 'Password1234'

payload = {
"NetworkDevice": {
"id": "5678",
"name": "TEST-DEVICE2",
"authenticationSettings": {
"networkProtocol": "RADIUS",
"radiusSharedSecret": "cisco1234",
"enableKeyWrap": False,
"keyInputFormat": "ASCII"
},
"tacacsSettings": {
"sharedSecret": "Cisco1234",
"connectModeOptions": "OFF",
"previousSharedSecret": "test123",
"previousSharedSecretExpiry": 0
},
"profileName": "Cisco",
"coaPort": 1700,
"NetworkDeviceIPList": [{
"ipaddress": "192.168.4.5",
"mask": 32
}],
"NetworkDeviceGroupList": ["Device Type#All Device Types#IPC#SWITCH#SLAN", "IPSEC#Is IPSEC Device#No", "Location#All Locations"]
}
}

response = requests.post(url, proxies={'http': None, 'https': None}, data=json.dumps(payload), auth=requests.auth.HTTPBasicAuth(username, password), headers=header, verify=False)
print(response)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 21:28:21 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-access-control/cisco-ise-3-1-restful-api-http-put-for-updating-nads-is-not/m-p/4696338#M577491</guid>
      <dc:creator>a.mitsova</dc:creator>
      <dc:date>2022-09-30T21:28:21Z</dc:date>
    </item>
  </channel>
</rss>

