12-09-2014 06:11 AM - edited 03-01-2019 02:46 AM
Has anyone used CRUD operations to add Network Devices within the REST API?
I have what I think is a properly formatted XML that I'm submitting to /Rest/NetworkDevice/Device, but I keep getting errors back from the service that don't make sense.
Here is my XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns1:devices
xmlns:ns1="networkdevice.rest.mgmt.acs.nm.cisco.com">
<device>
<description>Test - Created by REST</description>
<name>TEST-REST-TEST</name>
<groupInfo>
<groupName>All Locations</groupName>
<groupType>Location</groupType>
</groupInfo>
<groupInfo>
<groupName>All Device Types</groupName>
<groupType>Device Type</groupType>
</groupInfo>
<subnets>
<ipAddress>1.1.1.1</ipAddress>
<netMask>32</netMask>
</subnets>
<tacacsConnection>
<legacyTACACS>true</legacyTACACS>
<sharedSecret>******</sharedSecret>
<singleConnect>false</singleConnect>
</tacacsConnection>
</device>
</ns1:devices>
And the error the service is returning:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:restResult
xmlns:ns2="common.rest.mgmt.acs.nm.cisco.com">
<errorCode>61000</errorCode>
<httpCode>400</httpCode>
<moreErrInfo>XML Parsing Error: unexpected element (uri:"networkdevice.rest.mgmt.acs.nm.cisco.com", local:"devices"). Expected elements are <{networkdevice.rest.mgmt.acs.nm.cisco.com}device>. </moreErrInfo>
<operationType>NOT_AVAILABLE</operationType>
<resourceType>NOT_AVAILABLE</resourceType>
<status>BAD_REQUEST</status>
</ns2:restResult>
Solved! Go to Solution.
12-15-2014 10:58 AM
Try this
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns1:device xmlns:ns1="networkdevice.rest.mgmt.acs.nm.cisco.com">
<description>Test - Created by REST</description>
<name>TEST-REST-TEST</name>
<groupInfo>
<groupName>All Locations</groupName>
<groupType>Location</groupType>
</groupInfo>
<groupInfo>
<groupName>All Device Types</groupName>
<groupType>Device Type</groupType>
</groupInfo>
<groupInfo>
<groupName>All Hardware types:F5ve</groupName>
<groupType>Hardware Type</groupType>
</groupInfo>
<subnets>
<ipAddress>1.1.1.1</ipAddress>
<netMask>32</netMask>
</subnets>
<tacacsConnection>
<legacyTACACS>true</legacyTACACS>
<sharedSecret>helloAll</sharedSecret>
<singleConnect>false</singleConnect>
</tacacsConnection>
</ns1:device>
12-15-2014 10:58 AM
Try this
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns1:device xmlns:ns1="networkdevice.rest.mgmt.acs.nm.cisco.com">
<description>Test - Created by REST</description>
<name>TEST-REST-TEST</name>
<groupInfo>
<groupName>All Locations</groupName>
<groupType>Location</groupType>
</groupInfo>
<groupInfo>
<groupName>All Device Types</groupName>
<groupType>Device Type</groupType>
</groupInfo>
<groupInfo>
<groupName>All Hardware types:F5ve</groupName>
<groupType>Hardware Type</groupType>
</groupInfo>
<subnets>
<ipAddress>1.1.1.1</ipAddress>
<netMask>32</netMask>
</subnets>
<tacacsConnection>
<legacyTACACS>true</legacyTACACS>
<sharedSecret>helloAll</sharedSecret>
<singleConnect>false</singleConnect>
</tacacsConnection>
</ns1:device>
12-15-2014 11:10 AM
I did solve this on my own, just forgot to update the post, here was my template(but yours works too!):
<ns1:device xmlns:ns1="networkdevice.rest.mgmt.acs.nm.cisco.com">
<description>$devicedesc</description>
<name>$devicename</name>
<groupInfo>
<groupName>All Locations</groupName>
<groupType>Location</groupType>
</groupInfo>
<groupInfo>
<groupName>All Device Types</groupName>
<groupType>Device Type</groupType>
</groupInfo>
<subnets>
<ipAddress>$deviceIP</ipAddress>
<netMask>$deviceMask</netMask>
</subnets>
<tacacsConnection>
<legacyTACACS>true</legacyTACACS>
<sharedSecret>$acskey</sharedSecret>
<singleConnect>false</singleConnect>
</tacacsConnection>
</ns1:device>
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide