09-30-2014 07:16 AM - edited 03-01-2019 02:46 AM
Hello!,
I'm trying to use the REST API on a ACS 5.5 server to:
1. retrieve a list of all the Network Devices
2. Retrieve a list of all the Network devices that belong to a specific Network Device Group.
At this moment I have tried the REST Client add-on for Firefox, when I do a GET operation on the server with the URL https://10.254.4.68/Rest/NetworkDevice/Device It retrieves all the Network Devices (which is great!)
The problem is when I try to filter:
I do a PUT operation with the URL: https://10.254.4.68/Rest/NetworkDevice/Device/op/query
I add the following in the body field:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:query xmlns:ns2="query.rest.mgmt.acs.nm.cisco.com">
<criteria xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:type="ns2:AndFilter">
<simpleFilters>
<propertyName>name</propertyName>
<operation>NOT_EQUALS</operation>
<value>X</value>
</simpleFilters>
<simpleFilters>
<propertyName>name</propertyName>
<operation>CONTAINS</operation>
<value>T</value>
</simpleFilters>
</criteria>
<numberOfItemsInPage>100</numberOfItemsInPage>
<startPageNumber>1</startPageNumber>
</ns2:query>
And from the response headers I get:
- Status Code: 415 Unsupported Media Type
- Cache-Control: no-cache
- Content-Type: text/xml
- Date: Mon, 29 Sep 2014 21:03:24 GMT
- Expires: Wed, 31 Dec 1969 19:00:00 EST
- Pragma: No-cache
- Server: ACS 5.4
- Transfer-Encoding: chunked
Any ideas, could it be the XML format I'm passing to the server?
Thanks
10-08-2014 04:53 AM
Hi Angel,
I think XML format is correct. Can you try HTTP GET
HTTP PUT—Update an existing object. PUT is also used to invoke extrinsic methods (other than CRUD).
When HTTP PUT method is used for operations other than CRUD, the URL specifies the required operation. This is also used to distinguish the message from PUT method for update. The keyword "op" is included in the URL as follows:
Rest/{package}/{ObjectType}/op/{operation}
For example, /Rest/Identity/IdentityGroup/op/query
Reference - HTTP Methods
Thanks and Regards,
Geevarghese
01-28-2016 07:49 AM
For posterity sake and to help other poor SOB's like me trying to figure it out here is the solution:
The real issue is your XML is searching the "name" field, not a network device group. In my example I have a custom NDG called "Primary OU". The below will match all devices in Primary OU:MARS
URL: https://<Device name or IP>/Rest/NetworkDevice/Device/op/query
Header: Content-type:application/xml
Method: PUT
Body:
<ns2:query xmlns:ns2="query.rest.mgmt.acs.nm.cisco.com">
<criteria xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:AndFilter">
<simpleFilters>
<propertyName>Primary OU</propertyName>
<operation>CONTAINS</operation>
<value>MARS</value>
</simpleFilters>
</criteria>
<numberofItemsInPage>100</numberofItemsInPage>
<startPageNumber>1</startPageNumber>
</ns2:query>
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