Cisco APIC REST API Configuration Guide 42x
Cisco APIC REST API Configuration Guide 42x
2(x)
First Published: 2019-09-08
Last Modified: 2020-01-06
Americas Headquarters
Cisco Systems, Inc.
170 West Tasman Drive
San Jose, CA 95134-1706
USA
http://www.cisco.com
Tel: 408 526-4000
800 553-NETS (6387)
Fax: 408 527-0883
THE SPECIFICATIONS AND INFORMATION REGARDING THE PRODUCTS IN THIS MANUAL ARE SUBJECT TO CHANGE WITHOUT NOTICE. ALL STATEMENTS,
INFORMATION, AND RECOMMENDATIONS IN THIS MANUAL ARE BELIEVED TO BE ACCURATE BUT ARE PRESENTED WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED. USERS MUST TAKE FULL RESPONSIBILITY FOR THEIR APPLICATION OF ANY PRODUCTS.
THE SOFTWARE LICENSE AND LIMITED WARRANTY FOR THE ACCOMPANYING PRODUCT ARE SET FORTH IN THE INFORMATION PACKET THAT SHIPPED WITH
THE PRODUCT AND ARE INCORPORATED HEREIN BY THIS REFERENCE. IF YOU ARE UNABLE TO LOCATE THE SOFTWARE LICENSE OR LIMITED WARRANTY,
CONTACT YOUR CISCO REPRESENTATIVE FOR A COPY.
The Cisco implementation of TCP header compression is an adaptation of a program developed by the University of California, Berkeley (UCB) as part of UCB's public domain version of
the UNIX operating system. All rights reserved. Copyright © 1981, Regents of the University of California.
NOTWITHSTANDING ANY OTHER WARRANTY HEREIN, ALL DOCUMENT FILES AND SOFTWARE OF THESE SUPPLIERS ARE PROVIDED “AS IS" WITH ALL FAULTS.
CISCO AND THE ABOVE-NAMED SUPPLIERS DISCLAIM ALL WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THOSE OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OR ARISING FROM A COURSE OF DEALING, USAGE, OR TRADE PRACTICE.
IN NO EVENT SHALL CISCO OR ITS SUPPLIERS BE LIABLE FOR ANY INDIRECT, SPECIAL, CONSEQUENTIAL, OR INCIDENTAL DAMAGES, INCLUDING, WITHOUT
LIMITATION, LOST PROFITS OR LOSS OR DAMAGE TO DATA ARISING OUT OF THE USE OR INABILITY TO USE THIS MANUAL, EVEN IF CISCO OR ITS SUPPLIERS
HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Any Internet Protocol (IP) addresses and phone numbers used in this document are not intended to be actual addresses and phone numbers. Any examples, command display output, network
topology diagrams, and other figures included in the document are shown for illustrative purposes only. Any use of actual IP addresses or phone numbers in illustrative content is unintentional
and coincidental.
All printed copies and duplicate soft copies of this document are considered uncontrolled. See the current online version for the latest version.
Cisco has more than 200 offices worldwide. Addresses and phone numbers are listed on the Cisco website at www.cisco.com/go/offices.
Cisco and the Cisco logo are trademarks or registered trademarks of Cisco and/or its affiliates in the U.S. and other countries. To view a list of Cisco trademarks, go to this URL: www.cisco.com
go trademarks. Third-party trademarks mentioned are the property of their respective owners. The use of the word partner does not imply a partnership relationship between Cisco and any
other company. (1721R)
© 2019–2020 Cisco Systems, Inc. All rights reserved.
CONTENTS
Preface v
Audience v
Document Conventions v
Related Documentation vi
Documentation Feedback vii
Object Naming 5
Composing REST API Requests 6
Read and Write Operations and Filters 6
Using Classes in REST API Commands 8
Using Managed Objects in REST API Commands 9
Creating the API Command 10
Composing the API Command Body 11
Composing the API Command Body to Call a Method 12
Composing the API Command Body for an API Operation on an MO 13
Using Tags and Alias 14
Composing REST API Queries 16
Composing Query Filter Expressions 16
Applying Query Scoping Filters 18
Audience
This guide is intended primarily for data center administrators with responsibilities and expertise in one or
more of the following:
• Virtual machine installation and administration
• Server administration
• Switch and network administration
• Cloud administration
Document Conventions
Command descriptions use the following conventions:
Convention Description
bold Bold text indicates the commands and keywords that you enter literally
as shown.
Italic Italic text indicates arguments for which the user supplies the values.
variable Indicates a variable for which you supply values, in context where italics
cannot be used.
string A nonquoted set of characters. Do not use quotation marks around the
string or the string will include the quotation marks.
Convention Description
screen font Terminal sessions and information the switch displays are in screen font.
boldface screen font Information you must enter is in boldface screen font.
Convention Description
italic screen font Arguments for which you supply values are in italic screen font.
Note Means reader take note. Notes contain helpful suggestions or references to material not covered in the manual.
Caution Means reader be careful. In this situation, you might do something that could result in equipment damage or
loss of data.
Related Documentation
Cisco Application Centric Infrastructure (ACI) Documentation
The ACI documentation is available at the following URL: http://www.cisco.com/c/en/us/support/
cloud-systems-management/application-policy-infrastructure-controller-apic/
tsd-products-support-series-home.html.
Documentation Feedback
To provide technical feedback on this document, or to report an error or omission, please send your comments
to apic-docfeedback@cisco.com. We appreciate your feedback.
For JSON, encoding requires definition of certain entities to reflect the tree-based hierarchy; however, the
definition is repeated at all levels of the tree, so it is fairly simple to implement after it is initially understood.
• All objects are described as JSON dictionaries, in which the key is the name of the package and class.
The value is another nested dictionary with two keys: attribute and children.
• The attribute key contains a further nested dictionary describing key-value pairs that define attributes on
the object.
• The children key contains a list that defines all the child objects. The children in this list are dictionaries
containing any nested objects, which are defined as described here.
Authentication
REST API username- and password-based authentication uses a special subset of request Universal Resource
Identifiers (URIs), including aaaLogin, aaaLogout, and aaaRefresh as the DN targets of a POST operation.
Their payloads contain a simple XML or JSON payload containing the MO representation of an aaaUser
object with the attribute name and pwd defining the username and password: for example, <aaaUser
name='admin' pwd='password'/>. The response to the POST operation will contain an authentication token
as both a Set-Cookie header and an attribute to the aaaLogin object in the response named token, for which
the XPath is /imdata/aaaLogin/@token if the encoding is XML. Subsequent operations on the REST API
can use this token value as a cookie named APIC-cookie to authenticate future requests.
Subscription
The REST API supports the subscription to one or more MOs during your active API session. When any MO
is created, changed, or deleted because of a user- or system-initiated action, an event is generated. If the event
changes the data on any of the active subscribed queries, the APIC will send out a notification to the API
client that created the subscription.
you apply a profile to a switch), the DME first applies that change to the information model and then applies
the change to the actual managed endpoint. This approach is called a model-driven framework.
The following branch diagram of a leaf switch port starts at the top Root of the ACI fabric MIT and shows a
hierarchy that comprises a chassis with two line module slots, with a line module in slot 2.
|——root———————————–– (root)
|——sys———————————––– (sys)
|——ch————————————————(sys/ch)
|——lcslot-1——————————(sys/ch/lcslot-1)
|——lcslot-2——————————(sys/ch/lcslot-2)
|——lc————————————————(sys/ch/lcslot-2/lc)
|——leafport-1————————(sys/ch/lcslot-2/lc/leafport-1)
Object Naming
You can identify a specific object by its distinguished name (DN) or by its relative name (RN).
Note You cannot rename an existing object. To simplify references to an object or group of objects, you can assign
an alias or a tag.
Distinguished Name
The DN enables you to unambiguously identify a specific target object. The DN consists of a series of RNs:
dn = {rn}/{rn}/{rn}/{rn}...
In this example, the DN provides a fully qualified path for fabport-1 from the top of the object tree to the
object. The DN specifies the exact managed object on which the API call is operating.
Relative Name
The RN identifies an object from its siblings within the context of its parent object. The DN contains a sequence
of RNs.
For example, this DN:
<dn = "sys/ch/lcslot-1/lc/fabport-1"/>
Because the REST API is HTTP-based, defining the URI to access a certain resource type is important. The
first two sections of the request URI simply define the protocol and access details of the APIC. Next in the
request URI is the literal string /api, indicating that the API will be invoked. Generally, read operations are
for an object or class, as discussed earlier, so the next part of the URI specifies whether the operation will be
for an MO or class. The next component defines either the fully qualified domain name (DN) being queried
for object-based queries, or the package and class name for class-based queries. The final mandatory part of
the request URI is the encoding format: either .xml or .json. This is the only method by which the payload
format is defined. (The APIC ignores Content-Type and other headers.)
Write Operations
Both create and update operations in the REST API are implemented using the POST method, so that if an
object does not already exist, it will be created, and if it does already exist, it will be updated to reflect any
changes between its existing state and desired state.
Both create and update operations can contain complex object hierarchies, so that a complete tree can be
defined in a single command so long as all objects are within the same context root and are under the 1MB
limit for data payloads for the REST API. This limit is in place to guarantee performance and protect the
system under high loads.
The context root helps define a method by which the APIC distributes information to multiple controllers and
helps ensure consistency. For the most part, the configuration should be transparent to the user, though very
large configurations may need to be broken into smaller pieces if they result in a distributed transaction.
Figure 2: REST Payload
Create and update operations use the same syntax as read operations, except that they are always targeted at
an object level, because you cannot make changes to every object of a specific class (nor would you want to).
The create or update operation should target a specific managed object, so the literal string /mo indicates that
the DN of the managed object will be provided, followed next by the actual DN. Filter strings can be applied
to POST operations; if you want to retrieve the results of your POST operation in the response, for example,
you can pass the rsp-subtree=modified query string to indicate that you want the response to include any
objects that have been modified by your POST operation.
The payload of the POST operation will contain the XML or JSON encoded data representing the MO that
defines the Cisco API command body.
Filters
Note For a Cisco APIC REST API query of event records, the APIC system limits the response to a maximum of
500,000 event records. If the response is more than 500,000 events, it returns an error. Use filters to refine
your queries. For more information, see the section "Composing Query Filter Expressions" in the Cisco APIC
REST API Configuration Guide.
The REST API supports a wide range of flexible filters, useful for narrowing the scope of your search to allow
information to be located more quickly. The filters themselves are appended as query URI options, starting
with a question mark (?) and concatenated with an ampersand (&). Multiple conditions can be joined together
to form complex filters.
The following query filters are available:
All the physical and logical components that make up the Cisco Application Centric Infrastructure (ACI)
fabric are represented in a hierarchical management information tree (MIT). Each node in the tree represents
a managed object (MO) or group of objects that contains its administrative state and its operational state.
To access the complete list of classes, point to the APIC and reference the doc/html directory at the end
of the URL:
https://apic-ip-address/doc/html/
When you send an API command, the APIC checks the command for conformance with the MIM schema. If
an API command violates the MIM schema, the APIC rejects the command and returns an error message. For
example, you can create an MO only if it is allowed in the path you have specified in the command URI and
only if you have the required privilege level for that object class. You can configure an MO's properties only
with valid data, and you cannot create properties.
When composing an API command to create an MO, you need only include enough information in the
command's URI and data structure to uniquely define the new MO. If you omit the configuration of a property
when creating the MO, the property is populated with a default value if the MIM specifies one, or it is left
blank.
When modifying a property of an MO, you need only specify the property to be modified and its new value.
Other properties will be left unchanged.
• When you read an existing MO, any password property of the MO is read as blank for security reasons.
If you then write the MO back to APIC, the password property is written as blank.
Tip If you need to store an MO with its password information, use a configuration
export policy. To store a specific MO, specify the MO as the target distinguished
name in the policy.
https://apic-ip-address/api/mo/uni/tn-ExampleCorp.xml
URI Components
The components of the URI are as follows:
• http:// or https://—Specifies HTTP or HTTPS. By default, only HTTPS is enabled. HTTP or
HTTP-to-HTTPS redirection, if desired, must be explicitly enabled and configured, as described in
Configuring HTTP and HTTPS Using the GUI, on page 33. HTTP and HTTPS can coexist.
• host—Specifies the hostname or IP address of the APIC.
• :port—Specifies the port number for communicating with the APIC. If your system uses standard port
numbers for HTTP (80) or HTTPS (443), you can omit this component.
• /api/—Specifies that the message is directed to the API.
• mo | class—Specifies whether the target of the operation is an MO or an object class.
• dn—Specifies the distinguished name (DN) of the targeted MO.
• className—Specifies the name of the targeted class. This name is a concatenation of the package name
of the object queried and the name of the class queried in the context of the corresponding package.
For example, the class aaa:User results in a className of aaaUser in the URI.
• json | xml—Specifies whether the encoding format of the command or response HTML body is JSON
or XML.
• ?options—(Optional) Specifies one or more filters, selectors, or modifiers to a query. Multiple option
statements are joined by an ampersand (&).
https://apic-ip-address/api/mo/uni/tn-ExampleCorp.xml
Alternatively, in a POST operation, you can POST to /api/mo and provide the DN in the body of the message,
as in this example:
POST https://apic-ip-address/api/mo.xml
<fvTenant dn="uni/tn-ExampleCorp"/>
You can also provide only the name in the message body and POST to /api/mo and the remaining RN
components, as in this example:
POST https://apic-ip-address/api/mo/uni.xml
<fvTenant name="ExampleCorp"/>
GET https://apic-ip-address/api/mo/topology/pod-1/node-1/sys/ch/bslot/board/sensor-3.json
GET https://apic-ip-address/api/class/aaaUser.json
the MO and to execute the command, not including properties or parameters that are incorporated into
the URI.
• The data structure is a single tree in which all child nodes are unique with a unique DN. Duplicate nodes
are not allowed. You cannot make two changes to a node by including the same node twice. In this case,
you must merge your changes into a single node.
• In the data structure, the colon after the package name is omitted from class names and method names.
For example, in the data structure for an MO of class zzz:Object, label the class element as zzzObject.
• Although the JSON specification allows unordered elements, the APIC REST API requires that the JSON
'attributes' element precede the 'children' array or other elements.
• If an XML data structure contains no children or subtrees, the object element can be self-closing.
• The API is case sensitive.
• When sending an API command, with 'api' in the URL, the maximum size of the HTML body for the
API POST command is 1 MB.
• When uploading a device package file, with 'ppi' in the URL, the maximum size of the HTML body for
the POST command is 10 MB.
Method config:Method(
inParameter1,
inParameter2,
inParameter3,
outParameter1,
outParameter2
)
The parameters beginning with "in" represent the input parameters. The parameters beginning with "out"
represent values returned by the method. Parameters with no "in" or "out" prefix are input parameters.
A JSON structure to call the method resembles the following structure:
{
"configMethod":
{
"attributes":
{
"inParameter1":"value1",
"inParameter2":"value2",
"inParameter3":"value3"
}
}
<configMethod
inParameter1="value1"
inParameter2="value2"
inParameter3="value3"
/>
Note The parameters of some methods include a substructure, such as filter settings or configuration settings for
an MO. For specific information, see the method description in the Cisco APIC Management Information
Model Reference.
{
"zzzObject" : {
"attributes" : {
"property1" : "value1",
"property2" : "value2",
"property3" : "value3"
},
"children" :
[{
"zzzChild1" : {
"attributes" : {
"childProperty1" : "childValue1",
"childProperty2" : "childValue1"
},
"children" : []
}
}
]
}
}
<zzzObject
property1 = "value1",
property2 = "value2",
property3 = "value3">
<zzzChild1
childProperty1 = "childValue1",
childProperty2 = "childValue1">
</zzzChild1>
</zzzObject>
Note Not every object supports a tag. To determine whether an object is taggable, inspect the class of the object in
the Cisco APIC Management Information Model Reference. If the contained hierarchy of the object class
includes a tag instance (such as tag:AInst or a class that derives from tag:AInst), an object of that class can
be tagged.
Adding Tags
You can add one or more tags by using the following syntax in the URI of an API POST operation:
POST https://apic-ip-address/api/tag/mo/uni/tn-ExampleCorp.xml?add=tenants,orgs
Removing Tags
You can remove one or more tags by using the following syntax in the URI of an API POST operation:
POST https://apic-ip-address/api/tag/mo/uni/tn-ExampleCorp.xml?remove=orgs
You can delete all instances of a tag by using the following syntax in the URI of an API DELETE operation:
/api//tag/name.{json | xml}
This example shows how to remove the tag orgs from all objects:
DELETE https://apic-ip-address/api/tag/orgs.xml
Adding an Alias
You can add an alias by using the following syntax in the URI of an API POST operation:
/api/alias/mo/dn.{json | xml}?set=name
In this syntax, name is the name of the alias and dn is the distinguished name of the object to which the alias
is assigned.
This example shows how to assign the alias tenant8 to the tenant named ExampleCorp:
POST https://apic-ip-address/api/alias/mo/uni/tn-ExampleCorp.xml?set=tenant8
Removing an Alias
You can remove an alias by using the following syntax in the URI of an API POST operation:
/api/alias/mo/dn.{json | xml}?clear=yes
This example shows how to remove any alias from the tenant named ExampleCorp:
POST https://apic-ip-address/api/alias/mo/uni/tn-ExampleCorp.xml?clear=yes
Additional Examples
Note In the examples in this section, the responses have been edited to remove attributes unrelated to tags.
This example shows how to find all tags assigned to the tenant named ExampleCorp:
GET https://apic-ip-address/api/tag/mo/uni/tn-ExampleCorp.xml
RESPONSE:
<imdata>
<tagInst
dn="uni/tn-ExampleCorp/tag-tenants"
name="tenants"
/>
<tagInst
dn="uni/tn-ExampleCorp/tag-orgs"
name="orgs"
/>
</imdata>
This example shows how to find all objects with the tag 'tenants':
GET https://apic-ip-address/api/tag/tenants.xml
RESPONSE:
<imdata>
<fvTenant
dn="uni/tn-ExampleCorp"
name="ExampleCorp"
/>
</imdata>
query-target-filter=[eq|ne](attribute,value)
You can create a more complex test by combining operators and conditions using parentheses and commas:
query-target-filter=[and|or]([eq|ne](attribute,value),[eq|ne](attribute,value),...)
Note A scoping filter can contain a maximum of 20 '(attribute,value)' filter expressions. If the limit is exceeded,
the API returns an error.
Operator Description
eq Equal to
ne Not equal to
lt Less than
gt Greater than
bw Between
Operator Description
or Logical OR
wcard Wildcard
Examples
This example returns all managed objects of class aaaUser whose last name is equal to "Washington":
GET https://apic-ip-address/api/class/aaaUser.json?
query-target-filter=eq(aaaUser.lastName,"Washington")
GET https://apic-ip-address/api/class/fvAEPg.xml?
query-target-filter=eq(fvAEPg.fabEncap,"vxlan-12780288")
This example shows all tenant objects with a current health score of less than 50:
GET https://apic-ip-address/api/class/fvTenant.json?
rsp-subtree-include=health,required
&
rsp-subtree-filter=lt(healthInst.cur,"50")
This example returns all endpoint groups and their faults under the tenant ExampleCorp:
GET https://apic-ip-address/api/mo/uni/tn-ExampleCorp.xml?
query-target=subtree
&
target-subtree-class=fvAEPg
&
rsp-subtree-include=faults
This example returns aaa:Domain objects whose names are not "infra" or "common":
GET https://apic-ip-address/api/class/aaaDomain.json?
query-target-filter=
and(ne(aaaDomain.name,"infra"),
ne(aaaDomain.name,"common"))
target-subtree-class=mo-class1[,mo-class2]...
This statement specifies which object classes are to be considered when the query-target option is used with
a scope other than self. You can specify multiple desired object types as a comma-separated list with no spaces.
To request subtree information, combine query-target=subtree with the target-subtree-class statement to
indicate the specific subtree as follows:
query-target=subtree&target-subtree-class=className
This example requests information about the running firmware. The information is contained in the
firmware:CtrlrRunning subtree (child) object of the APIC firmware status container
firmware:CtrlrFwStatusCont:
GET https://apic-ip-address/api/class/firmwareCtrlrFwStatusCont.json?
query-target=subtree&target-subtree-class=firmwareCtrlrRunning
query-target-filter=filter-expression
This statement specifies a logical filter to be applied to the response. This statement can be used by itself or
applied after the query-target statement.
rsp-subtree-class=mo-class
When child objects are to be returned, this statement specifies that only child objects of the specified object
class are included in the response.
rsp-subtree-filter=filter-expression
When child objects are to be returned, this statement specifies a logical filter to be applied to the child objects.
Note When an rsp-subtree-filter query statement includes a class.property operand, the specified class name is
used only to identify the property and its type. The returned results are not filtered by class, and may include
any child object that contains a property of the same name but belonging to a different class if that object's
property matches the query condition. To filter by class, you must use additional query filters.
rsp-subtree-include=category1[,category2...][option]
When child objects are to be returned, this statement specifies additional contained objects or options to be
included in the response. You can specify one or more of the following categories in a comma-separated list
with no spaces:
• audit-logs—Response includes subtrees with the history of user modifications to managed objects.
• event-logs—Response includes subtrees with event history information.
• faults—Response includes subtrees with currently active faults.
• fault-records—Response includes subtrees with fault history information.
• health—Response includes subtrees with current health information.
• health-records—Response includes subtrees with health history information.
• relations—Response includes relations-related subtree information.
• stats—Response includes statistics-related subtree information.
• tasks—Response includes task-related subtree information.
With any of the preceding categories, you can also specify one of the following options to further refine the
query results:
• count—Response includes a count of matching subtrees but not the subtrees themselves.
• no-scoped—Response includes only the requested subtree information. Other top-level information of
the target MO is not included in the response.
• required—Response includes only the managed objects that have subtrees matching the specified
category.
For example, to include fault-related subtrees, specify faults in the list. To return only fault-related subtrees
and no other top-level MO information, specify faults,no-scoped in the list as shown in this example:
query-target=subtree&rsp-subtree-include=faults,no-scoped
Note Some types of child objects are not created until the parent object has been pushed to a fabric node (leaf).
Until such a parent object has been pushed to a fabric node, a query on the parent object using the
rsp-subtree-include filter might return no results. For example, a class query for fvAEPg that includes the
query option rsp-subtree-include=stats will return stats only for endpoint groups that have been applied
to a tenant and pushed to a fabric node.
Note If the managed object is not configurable or cannot be exported (backed up), the
managed object is not returned.
Related Topics
Composing Query Filter Expressions, on page 16
Example: Using the JSON API to Get Running Firmware, on page 28
https://URI?condition[&condition[&...]]
Operator Description
eq Equal to
Operator Description
ne Not equal to
lt Less than
gt Greater than
bw Between
or Logical OR
wcard Wildcard
GET
https://apic-ip-address/api/class/aaaUser.json?order-by=aaaUser.lastName|asc,aaaUser.firstName|asc
page-size=number-of-objects-per-page
By adding the page operator in the query URI, you can specify a single group to be returned using the following
syntax. The pages start from number 0.
page=page-number
This example shows you how to specify 15 fault instances per page in descending order, returning only the
first page:
GET
https://apic-ip-address/api/class/faultInfo.json?order-by=faultInst.severity|desc&page=0&page-size=15
Note Every query, whether paged or not, generates a new set of results. When you perform a query that returns
only a single page, the query response includes a count of the total results, but the unsent pages are not stored
and cannot be retrieved by a subsequent query. A subsequent query generates a new set of results and returns
the page requested in that query.
Opening a WebSocket
The API subscription feature uses the WebSocket protocol (RFC 6455) to implement a two-way connection
with the API client through which the API can send unsolicited notification messages to the client. To establish
this notification channel, you must first open a WebSocket connection with the API. Only a single WebSocket
connection is needed to support multiple query subscriptions with multiple APIC instances. The WebSocket
connection is dependent on your API session connection, and closes when your API session ends.
Note When MO events go through the event manager (eventmgr), clients receive notification of WebSocket
subscription for any MO. Although most of the APIC MOs do go through eventmgr, stats objects do not go
through it, because updates are very frequent and not scalable. Therefore, if you subscribe to stats objects,
you will receive no notification. Instead you can periodically query or export stats MOs.
In the URI, the %TOKEN% is the current API session token (cookie). This example shows the URI with a
token:
https://apic-ip-address/socketGkZl5NLRZJl5+jqChouaZ9CYjgE58W/pMccR+LeXmdO0obG9NB
Iwo1VBo7+YC1oiJL9mS6I9qh62BkX+Xddhe0JYrTmSG4JcKZ4t3bcP2Mxy3VBmgoJjwZ76ZOuf9V9AD6X
l83lyoR4bLBzqbSSU1R2NIgUotCGWjZt5JX6CJF0=
After the WebSocket connection is established, it is not necessary to resend the API session token when the
API session is refreshed.
Creating a Subscription
To create a subscription to a query, perform the query with the option ?subscription=yes. This example
creates a subscription to a query of the fv:Tenant class in the JSON format:
GET https://apic-ip-address/api/class/fvTenant.json?subscription=yes
GET https://apic-ip-address/api/class/fvTenant.json?&subscription=yes&refresh-timeout=140
The query response contains a subscription identifier, subscriptionId, that you can use to refresh the
subscription and to identify future notifications from this subscription.
{
"subscriptionId" : "72057611234574337",
"imdata" : [{
"fvTenant" : {
"attributes" : {
"instanceId" : "0:0",
"childAction" : "",
"dn" : "uni/tn-common",
"lcOwn" : "local",
"monPolDn" : "",
"name" : "common",
"replTs" : "never",
"status" : ""
}
}
}
]
}
Receiving Notifications
An event notification from the subscription delivers a data structure that contains the subscription ID and the
MO description. In this JSON example, a new user has been created with the name "sysadmin5":
{
"subscriptionId" : ["72057598349672454", "72057598349672456"],
"imdata" : [{
"aaaUser" : {
"attributes" : {
"accountStatus" : "active",
"childAction" : "",
"clearPwdHistory" : "no",
"descr" : "",
"dn" : "uni/userext/user-sysadmin5",
"email" : "",
"encPwd" : "TUxISkhH$VHyidGgBX0r7N/srt/YcMYTEn5248ommFhNFzZghvAU=",
"expiration" : "never",
"expires" : "no",
"firstName" : "",
"intId" : "none",
"lastName" : "",
"lcOwn" : "local",
"name" : "sysadmin5",
"phone" : "",
"pwd" : "",
"pwdLifeTime" : "no-password-expire",
"pwdSet" : "yes",
"replTs" : "2013-05-30T11:28:33.835",
"rn" : "",
"status" : "created"
}
}
}
]
}
Because multiple active subscriptions can exist for a query, a notification can contain multiple subscription
IDs as in the example shown.
GET https://apic-ip-address/api/subscriptionRefresh.json?id=72057611234574337
The API returns an empty response to the refresh message unless the subscription has expired.
Note The timeout period for a subscription is one minute. To prevent lost notifications, you must send a subscription
refresh message at least once every 60 seconds.
Example: Using the JSON API to Add a Leaf Port Selector Profile
This example shows how to add a leaf port selector profile.
As shown in the Cisco APIC Management Information Model Reference, this hierarchy of classes forms a
leaf port selector profile:
• fabric:LePortP — A leaf port profile is represented by a managed object (MO) of this class, which has
a distinguished name (DN) format of uni/fabric/leportp-[name], in which leportp-[name] is the
relative name (RN). The leaf port profile object is a template that can contain a leaf port selector as a
child object.
• fabric:LFPortS — A leaf port selector is represented by an MO of this class, which has a RN format
of lefabports-[name]-typ-[type]. The leaf port selector object can contain one or more ports or
ranges of ports as child objects.
• fabric:PortBlk — A leaf port or a range of leaf ports is represented by an MO of this class,
which has a RN format of portblk-[name].
The API command that creates the new leaf port selector profile MO can also create and configure the child
MOs.
This example creates a leaf port selector profile with the name "MyLPSelectorProf." The example profile
contains a selector named "MySelectorName" that selects leaf port 1 on leaf switch 1 and leaf ports 3 through
5 on leaf switch 1. To create and configure the new profile, send this HTTP POST message:
POST http://apic-ip-address/api/mo/uni/fabric/leportp-MyLPSelectorProf.json
{
"fabricLePortP" : {
"attributes" : {
"descr" : "Selects leaf ports 1/1 and 1/3-5"
},
"children" : [{
"fabricLFPortS" : {
"attributes" : {
"name" : "MySelectorName",
"type" : "range"
},
"children" : [{
"fabricPortBlk" : {
"attributes" : {
"fromCard" : "1",
"toCard" : "1",
"fromPort" : "1",
"toPort" : "1",
"name" : "block2"
}
}
}, {
"fabricPortBlk" : {
"attributes" : {
"fromCard" : "1",
"toCard" : "1",
"fromPort" : "3",
"toPort" : "5",
"name" : "block3"
}
}
}
]
}
}
]
}
}
{
"imdata" : [{
"fabricLePortP" : {
"attributes" : {
"instanceId" : "0:0",
"childAction" : "deleteNonPresent",
"descr" : "Select leaf ports 1/1 and 1/3-5",
"dn" : "uni/fabric/leportp-MyLPSelectorProf",
"lcOwn" : "local",
"name" : "MyLPSelectorProf",
"replTs" : "never",
"rn" : "",
"status" : "created"
},
"children" : [{
"fabricLFPortS" : {
"attributes" : {
"instanceId" : "0:0",
"childAction" : "deleteNonPresent",
"dn" : "",
"lcOwn" : "local",
"name" : "MySelectorName",
"replTs" : "never",
"rn" : "lefabports-MySelectorName-typ-range",
"status" : "created",
"type" : "range"
},
"children" : [{
"fabricPortBlk" : {
"attributes" : {
"instanceId" : "0:0",
"childAction" : "deleteNonPresent",
"dn" : "",
"fromCard" : "1",
"fromPort" : "3",
"lcOwn" : "local",
"name" : "block3",
"replTs" : "never",
"rn" : "portblk-block3",
"status" : "created",
"toCard" : "1",
"toPort" : "5"
}
}
}, {
"fabricPortBlk" : {
"attributes" : {
"instanceId" : "0:0",
"childAction" : "deleteNonPresent",
"dn" : "",
"fromCard" : "1",
"fromPort" : "1",
"lcOwn" : "local",
"name" : "block2",
"replTs" : "never",
"rn" : "portblk-block2",
"status" : "created",
"toCard" : "1",
"toPort" : "1"
}
}
}
]
}
}
]
}
}
]
}
To delete the new profile, send an HTTP POST message with a fabricLePortP attribute of "status":"deleted",
as in this example:
POST http://apic-ip-address/api/mo/uni/fabric/leportp-MyLPSelectorProf.json
{
"fabricLePortP" : {
"attributes" : {
"status" : "deleted"
}
}
}
DELETE http://apic-ip-address/api/mo/uni/fabric/leportp-MyLPSelectorProf.json
GET http://apic-ip-address/api/mo/topology/pod-1/node-1/sys/ch/bslot/board/sensor-3.json
{
"imdata" :
[{
"eqptSensor" : {
"attributes" : {
"instanceId" : "0:0",
"childAction" : "",
"dn" : "topology/pod-1/node-1/sys/ch/bslot/board/sensor-3",
"id" : "3",
"majorThresh" : "0",
"mfgTm" : "not-applicable",
"minorThresh" : "0",
"model" : "",
"monPolDn" : "",
"rev" : "0",
"ser" : "",
"status" : "",
"type" : "dimm",
"vendor" : "Cisco Systems, Inc."
}
}
}
]
}
GET http://apic-ip-address/api/class/firmware:CtrlrFwStatusCont.json?
query-target=subtree
&
target-subtree-class=firmwareCtrlrRunning
{
"imdata" : [{
"firmwareCtrlrRunning" : {
"attributes" : {
"instanceId" : "0:0",
"applId" : "3",
"childAction" : "",
"dn" : "Ctrlrfwstatuscont/ctrlrrunning-3",
"lcOwn" : "local",
"replTs" : "never",
"rn" : "",
"status" : "",
"ts" : "2012-12-31T16:00:00.000",
"type" : "ifc",
"version" : "1.1"
}
}
}, {
"firmwareCtrlrRunning" : {
"attributes" : {
"instanceId" : "0:0",
"applId" : "1",
"childAction" : "",
"dn" : "ctrlrfwstatuscont/ctrlrrunning-1",
"lcOwn" : "local",
"replTs" : "never",
"rn" : "",
"status" : "",
"ts" : "2012-12-31T16:00:00.000",
"type" : "ifc",
"version" : "1.1"
}
}
}, {
"firmwareCtrlrRunning" : {
"attributes" : {
"instanceId" : "0:0",
"applId" : "2",
"childAction" : "",
"dn" : "ctrlrfwstatuscont/ctrlrrunning-2",
"lcOwn" : "local",
"replTs" : "never",
"rn" : "",
"status" : "",
"ts" : "2012-12-31T16:00:00.000",
"type" : "ifc",
"version" : "1.1"
}
}
}
]
}
This response describes three running instances of APIC firmware version 1.1.
Example: Using the JSON API to Get Top Level System Elements
This example shows how to query the APIC to determine what system devices are present.
General information about the system elements (APICs, spines, and leafs) is contained in an object of class
top:System.
GET http://apic-ip-address/api/class/topSystem.json
{
"imdata" :
[{
"topSystem" : {
"attributes" : {
"instanceId" : "0:0",
"address" : "10.0.0.32",
"childAction" : "",
"currentTime" : "2013-06-14T04:13:05.584",
"currentTimeZone" : "",
"dn" : "topology/pod-1/node-17/sys",
"fabricId" : "0",
"id" : "17",
"inbMgmtAddr" : "0.0.0.0",
"lcOwn" : "local",
"mode" : "unspecified",
"name" : "leaf0",
"nodeId" : "0",
"oobMgmtAddr" : "0.0.0.0",
"podId" : "1",
"replTs" : "never",
"role" : "leaf",
"serial" : "FOX-270308",
"status" : "",
"systemUpTime" : "00:00:02:03"
}
}
}, {
"topSystem" : {
"attributes" : {
"instanceId" : "0:0",
"address" : "10.0.0.1",
"childAction" : "",
"currentTime" : "2013-06-14T04:13:29.301",
"currentTimeZone" : "PDT",
"dn" : "topology/pod-1/node-1/sys",
"fabricId" : "0",
"id" : "1",
"inbMgmtAddr" : "0.0.0.0",
"lcOwn" : "local",
"mode" : "unspecified",
"name" : "apic0",
"nodeId" : "0",
"oobMgmtAddr" : "0.0.0.0",
"podId" : "0",
"replTs" : "never",
"role" : "apic",
"serial" : "",
"status" : "",
"systemUpTime" : "00:00:02:26"
}
}
}
]
}
This response indicates that the system consists of one APIC (node-1) and one leaf (node-17).
Example: Using the XML API and OwnerTag to Add Audit Log Information to
Actions
This example shows how to use the ownerTag or ownerKey property to add custom audit log information
when an object is created or modified.
All configurable objects contain the properties ownerTag and ownerKey, which are user-configurable string
properties. When any configurable object is created or modified by a user action, an audit log record object
(aaa:ModLR) is automatically created to contain information about the change to be reported in the audit
log. The audit log record object includes a list (the changeSet property) of the configured object's properties
that were changed by the action. In the command to create or modify the configurable object, you can add
your own specific tracking information, such as a job ticket number or the name of the person making the
change, to the ownerTag or ownerKey property of the configurable object. This tracking information will
then be included in the audit log record along with the details of the change.
Note The ownerTag information will appear in the log only when the ownerTag contents have been changed. To
include the same information in a subsequent configuration change, you can clear the ownerTag contents
before making the next configuration change. This condition applies also to the ownerKey property.
In the following example, a domain reference is added to a tenant configuration. As part of the command, the
operator's name is entered as the ownerKey and a job number is entered as the ownerTag.
POST https://apic-ip-address/api/mo/uni/tn-ExampleCorp.xml
In this case, two aaa:ModLR records are generated — one for the fv:Tenant object and one for the
aaa:DomainRef object. Unless the ownerKey or ownerTag properties are unchanged from a previous
configuration, their new values will appear in the changeSet list of the aaa:ModLR records, and this
information will appear in the audit log record that reports this configuration change.
Use an XML query, such as the following example, to get a list of endpoints with the IP and MAC address for each one:
Example:
GET https://apic-ip-address/api/node/class/fvCEp.xml
XML Example: Get the Current List of Faults in the Fabric That Were Caused by a Failed Configuration
You can also use the fault Inst class with filters to limit the response to faults that were caused by a failed
configuration, with XML such as this example:
GET https://apic-ip-address/api/node/class/faultInst.xml?
query-target-filter=and(e(stultification,"config-failure"))
By using a script or a browser-based REST client, you can send an API POST or GET message of the form:
https://apic-ip-address/api/api-message-url
Use the out-of-band management IP address that you configured during the initial setup.
Note • Only https is enabled by default. By default, http and http-to-https redirection are disabled.
• You must send an authentication message to initiate an API session. Use the administrator login name and
password that you configured during the initial setup.
body of the response message contains a JSON or XML structure that contains requested data, confirmation
of a requested action, or error information.
Note The root element of the response structure is imdata. This element is merely a container for the response; it
is not a class in the management information model (MIM).
Note For security, only HTTPS is enabled as the default mode for API communications. HTTP and
HTTP-to-HTTPS redirection can be enabled if desired, but are less secure. For simplicity, this document refers
to HTTP in descriptions of protocol components and interactions.
Request Methods
The API supports HTTP POST, GET, and DELETE request methods as follows:
• An API command to create or update an MO, or to execute a method, is sent as an HTTP POST message.
• An API query to read the properties and status of an MO, or to discover objects, is sent as an HTTP GET
message.
• An API command to delete an MO is sent as either an HTTP POST or DELETE message. In most cases,
you can delete an MO by setting its status to deleted in a POST operation.
Note Although the DELETE method is supported, the HTTP header might show only these:
Access-Control-Allow-Methods: POST, GET, OPTIONS
Content Type
The API supports either JSON or XML data structures in the HTML body of an API request or response. You
must specify the content type by terminating the URI pathname with a suffix of either .json or .xml to indicate
the format to be used. The HTTP Content-Type and Accept headers are ignored by the API.
Procedure
apic1(config-comm-policy)# https
apic1(config-https)#
Step 4 [no] enable-throttle Enable or disable throttling on the selected protocol. The
no prefix disables throttling.
Example:
apic1(config-https)# enable-throttle
apic1(config-https)#
Step 5 throttle 1-100 Set the maximum rate of requests per second.
Example:
apic1(config-https)# throttle 50
apic1(config-https)#
Configuring a Custom Certificate for Cisco ACI HTTPS Access Using the GUI
CAUTION: PERFORM THIS TASK ONLY DURING A MAINTENANCE WINDOW AS THERE IS A
POTENTIAL FOR DOWNTIME. The downtime affects access to the APIC cluster and switches from external
users or systems and not the APIC to switch connectivity. The NGINX process on the switches will also be
impacted but that will be only for external connectivity and not for the fabric data plane. Access to the APIC,
configuration, management, troubleshooting and such will be impacted. Expect a restart of all web servers in
the fabric during this operation.
In the Work pane, in the Key Rings area, the Admin State for the key ring created displays Started.
Step 13 In the Navigation pane, choose Public Key Management > Key Rings > key_ring_name.
Step 14 In the Work pane, choose Actions > Create Certificate Request.
Step 15 In the Subject field, enter the fully qualified domain name (FQDN) of the APIC.
Step 16 Fill in the remaining fields as appropriate.
Note Check the online help information available in the Create Certificate Request dialog box for a description
of the available parameters.
The key is verified, and in the Work pane, the Admin State changes to Completed and is now ready for use in the
HTTP policy.
Step 21 On the menu bar, choose Fabric > Fabric Policies.
Step 22 In the Navigation pane, choose Pod Policies > Policies > Management Access > default.
Step 23 In the Work pane, in the Admin Key Ring drop-down list, choose the desired key ring.
Step 24 (Optional) For Certificate based authentication, in the Client Certificate TP drop-down list, choose the previously
created Local User policy and click Enabled for Client Certificate Authentication state.
Step 25 Click Submit.
All web servers restart. The certificate is activated, and the non-default key ring is associated with HTTPS access.
What to do next
You must remain aware of the expiration date of the certificate and take action before it expires. To preserve
the same key pair for the renewed certificate, you must preserve the CSR as it contains the public key that
pairs with the private key in the key ring. Before the certificate expires, the same CSR must be resubmitted.
Do not delete or create a new key ring as deleting the key ring will delete the private key stored internally on
the APIC.
• aaaLogin—Sent as a POST message, this method logs in a user and opens a session. The message body
contains an aaa:User object with the name and password attributes, and the response contains a session
token and cookie. If multiple AAA login domains are configured, you must prepend the user's name with
apic:domain\\.
• aaaRefresh—Sent as a GET message with no message body or as a POST message with the aaaLogin
message body, this method resets the session timer. The response contains a new session token and
cookie.
• aaaLogout—Sent as a POST message, this method logs out the user and closes the session. The message
body contains an aaa:User object with the name attribute. The response contains an empty data structure.
• aaaListDomains—Sent as a GET message, this method returns a list of valid AAA login domains. You
can send this message without logging in.
You can call the authentication methods using this syntax, specifying either JSON or XML data structures:
POST https://apic-ip-address/api/aaaLogin.json
{
"aaaUser" : {
"attributes" : {
"name" : "georgewa",
"pwd" : "paSSword1"
}
}
}
This example shows part of the response upon a successful login, including the token and the refresh timeout
period:
RESPONSE:
{
"imdata" : [{
"aaaLogin" : {
"attributes" : {
"token" :
"GkZl5NLRZJl5+jqChouaZ9CYjgE58W/pMccR+LeXmdO0obG9NB
Iwo1VBo7+YC1oiJL9mS6I9qh62BkX+Xddhe0JYrTmSG4JcKZ4t3
bcP2Mxy3VBmgoJjwZ76ZOuf9V9AD6Xl83lyoR4bLBzqbSSU1R2N
IgUotCGWjZt5JX6CJF0=",
"refreshTimeoutSeconds" : "300",
"lastName" : "Washington",
"firstName" : "George"
},
"children" : [{
...
[TRUNCATED]
...
}
In the preceding example, the refreshTimeoutSeconds attribute indicates that the session timeout period is
300 seconds.
GET https://apic-ip-address/api/aaaListDomains.json
RESPONSE:
{
"imdata": [{
"name": "ExampleRadius"
},
{
"name": "local",
"guiBanner": "San Jose Fabric"
}]
}
In the preceding example, the response data shows two possible login domains, 'ExampleRadius' and 'local.'
The following example shows a user login message for the ExampleRadius login domain:
POST https://apic-ip-address/api/aaaLogin.json
{
"aaaUser" : {
"attributes" : {
"name" : "apic:ExampleRadius\\georgewa",
"pwd" : "paSSword1"
}
}
}
To initiate a session that requires a challenge token, include the URI parameter statement
?gui-token-request=yes in your login message, as shown in this example:
POST https://192.0.20.123/api/aaaLogin.json?gui-token-request=yes
The response message body contains an attribute of the form "urlToken":"token", where token is a long
string of characters representing the challenge token. All subsequent messages to the API during this session
must include the challenge token, as shown in this example where it is sent as a 'challenge' URI parameter:
GET https://192.0.20.123/api/class/aaaUser.json?challenge=fa47e44df54562c24fef6601dc...
This example shows how the challenge token is sent as an 'APIC-challenge' field in the HTTP header:
GET //api/class/aaaUser.json
HTTP/1.1
Host: 192.0.20.123
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml,application/json
APIC-challenge: fa47e44df54562c24fef6601dcff72259299a077336aecfc5b012b036797ab0f
.
.
.
Logging In
You can log in to the APIC REST API by sending a valid username and password in a data structure to the
aaaLogin API method, as described in Authenticating and Maintaining an API Session, on page 36. Following
a successful login, you must periodically refresh the session.
The following examples show how to log in as an administrator, refresh the session during configuration, and
log out using XML and JSON.
Note At this time, the aaaLogout method returns a response but does not end a session. Your session ends after a
refresh timeout when you stop sending aaaRefresh messages.
Note Using these methods, you can change the credentials only for the account under which you are logged in.
The message body of each method contains the properties of the object to be modified. The properties are
shown in the Cisco APIC Management Information Model Reference.
This example, when sent by User1, changes the password for User1.
POST http://192.0.20.123/api/changeSelfPassword.json
{
"aaaChangePassword" : {
"attributes" : {
"userName" : "User1",
"oldPassword" : "p@$sw0rd",
"newPassword" : "dr0ws$@p"
}
}
}
{
"totalCount" : "0",
"imdata" : []
}
This example, when sent by User1, changes the SSH key for User1.
POST http://192.0.20.123/api/changeSelfSshKey.json
{
"aaaChangeSshKey" : {
"attributes" : {
"userName" : "User1",
"name" : "A",
"data" : "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuKxY5E4we6uCR2z== key@example.com"
}
}
}
This example, when sent by User1, changes the X.509 certificate for User1.
POST http://192.0.20.123/api/changeSelfX509Cert.json
{
"aaaChangeX509Cert" : {
"attributes" : {
"userName" : "User1",
"name" : "A",
"data" : "-----BEGIN CERTIFICATE-----\nMIIE2TCCA8GgAwIBAgIKamlnsw
[EXAMPLE TRUNCATED]
1BCIolblPFft6QKoSJFjB6thJksaE5/k3Npf\n-----END CERTIFICATE-----"
}
}
}
POST http://192.0.20.123/api/changeSelfSshKey.json
{
"aaaChangeSshKey" : {
"attributes" : {
"userName" : "User1",
"name" : "A",
"data" : ""
}
}
}
Step 4 In the Filters toolbar of the API Inspector window, choose the types of API log messages to display.
The displayed messages are color-coded according to the selected message types. This table shows the available message
types:
Name Description
trace Displays trace messages.
debug Displays debug messages. This type includes most API commands and responses.
info Displays informational messages.
warn Displays warning messages.
error Displays error messages.
fatal Displays fatal messages.
all Checking this checkbox causes all other checkboxes to become checked. Unchecking any other
checkbox causes this checkbox to be unchecked.
Step 5 In the Search toolbar, you can search the displayed messages for an exact string or by a regular expression.
This table shows the search controls:
Name Description
Search In this text box, enter a string for a direct search or enter a regular expression for a regex search.
As you type, the first matched field in the log list is highlighted.
Reset Click this button to clear the contents of the Search text box.
Regex Check this checkbox to use the contents of the Search text box as a regular expression for a search.
Match case Check this checkbox to make the search case sensitive.
Disable Check this checkbox to disable the search and clear the highlighting of search matches in the log
list.
Next Click this button to cause the log list to scroll to the next matched entry. This button appears only
when a search is active.
Name Description
Previous Click this button to cause the log list to scroll to the previous matched entry. This button appears
only when a search is active.
Filter Check this checkbox to hide nonmatched lines. This checkbox appears only when a search is active.
Highlight all Check this checkbox to highlight all matched fields. This checkbox appears only when a search is
active.
Step 6 In the Options toolbar, you can arrange the displayed messages.
This table shows the available options:
Name Description
Log Check this checkbox to enable logging.
Wrap Check this checkbox to enable wrapping of lines to avoid horizontal scrolling of the log list
Newest at the top Check this checkbox to display log entries in reverse chronological order.
Scroll to latest Check this checkbox to scroll immediately to the latest log entry.
Clear Click this button to clear the log list.
Close Click this button to close the API Inspector.
Example
This example shows two debug messages in the API Inspector window:
Browser add-ons pass the session token as a cookie so that there is no need to include the token in the payload
data structure.
You must specify the name of your descriptor file and the URI of the API operation.
Note Make sure to include the "@" symbol before the descriptor filename.
This example creates a new tenant named ExampleCorp using the JSON data structure in the file
"newtenant.json":
Note When testing with cURL, you must log in to the API, store the authentication token, and include the token in
subsequent API operations.
Related Topics
Example: Using the JSON API to Add a User with cURL
Cobra supports Python version 2.7 and later 2.x versions. Beginning in the APIC 4.2(3) release, Cobra supports
Python version 3.6 and later 3.x versions.
For more information, see Cisco APIC Python SDK Documentation, Installing the Cisco APIC Python SDK,
http://www.python-requests.org, and https://cobra.readthedocs.io/en/latest/.
Note Only the Firefox, Chrome, and Safari browsers are supported for Visore access.
Name Description
Class or DN field Object class name or fully distinguished name of a managed object.
Property field The property of the managed object on which you want to filter the
results. If you leave the Property field empty, the search returns all
instances of the specific class.
Op drop-down list Operator for the values of the property on which you want to filter the
results. The following are valid operators:
• == (equal to)
• != (not equal to)
• < (less than)
• > (greater than)
• ≤ (less than or equal to)
• ≥ (greater than or equal to)
• between
• wildcard
• anybit
• allbits
Val1 field The first value for the property on which you want to filter.
Name Description
Val2 field The second value on which you want to filter.
Results Area
You can bookmark any query results page in your browser to view the results again because the query is
encoded in the URL.
Note Many of the managed objects are only used internally and are not generally applicable to APIC REST API
program development.
Name Description
Pink background Separates individual managed object instances and displays the class
name of the object below it.
Blue or green background Indicates the property names of the managed object.
dn link When clicked, displays all managed objects with that dn.
Class name link When clicked, displays all managed objects of that class.
Left arrow When clicked, takes you to the parent object of the managed object.
Right arrow When clicked, takes you to the child objects of the managed object.
Question mark Links you to the XML API documentation for the managed object.
Accessing Visore
Step 1 Open a supported browser and enter the URL of the APIC followed by /visore.html.
Example:
https://apic-ip-address/visore.html
Step 2 When prompted, log in using the same credentials you would use to log in to the APIC CLI or GUI user interfaces.
Step 4 (Optional) Click the Display URI of last query link to display the API call that executed the query.
Step 5 (Optional) Click the Display last response link to display the API response data structure from the query.
Step 6 (Optional) In the dn field of the MO description table, click the < and > icons to retrieve the parent and child classes of
the displayed MO.
Clicking > sends a query to the APIC for the children of the MO. Clicking < sends a query for the parent of the MO.
Step 7 (Optional) In the dn field of the MO description table, click the additional icons to display statistics, faults, or health
information for the MO.