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

ACS REST API - Add Devices

jmannbaylor
Level 1
Level 1

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:&quot;networkdevice.rest.mgmt.acs.nm.cisco.com&quot;, local:&quot;devices&quot;). Expected elements are &lt;{networkdevice.rest.mgmt.acs.nm.cisco.com}device&gt;. </moreErrInfo>

    <operationType>NOT_AVAILABLE</operationType>

    <resourceType>NOT_AVAILABLE</resourceType>

    <status>BAD_REQUEST</status>

</ns2:restResult>

1 Accepted Solution

Accepted Solutions

rreddy2014
Level 1
Level 1

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>

View solution in original post

2 Replies 2

rreddy2014
Level 1
Level 1

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>

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>