10-05-2016 12:14 PM
Hello,
I am using the get query for Device object to get some specific information for the device like: Hostname, Ipaddress, collectionTime, location, and deviceType, howerver I am requiring to get an extra information that is located in InventoryDetails Object: udiSerialNr, Could I mix informationfrom Device and InventoryDetails?
a) Get Device: Getting all the parameters from Device:
https://szier-m8-106.cisco.com/webacs/api/v1/data/Devices
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<queryResponse rootUrl="https://szier-m8-106.cisco.com/webacs/api/v1/data" requestUrl="https://szier-m8-106.cisco.com/webacs/api/v1/data/Devices/42" responseType="getEntity">
<entity url="https://szier-m8-106.cisco.com/webacs/api/v1/data/Devices/15" type="Devices" dtoType="devicesDTO">
<devicesDTO id="15" displayName="String value">
<clearedAlarms>1</clearedAlarms>
<collectionDetail>String value</collectionDetail>
<collectionTime>2014-12-04T10:16:28.284-08:00</collectionTime>
<creationTime>2014-12-04T10:16:28.284-08:00</creationTime>
<criticalAlarms>1</criticalAlarms>
<deviceId>15</deviceId>
<deviceName>String value</deviceName>
<deviceType>String value</deviceType>
<informationAlarms>1</informationAlarms>
<ipAddress>String value</ipAddress>
<location>String value</location>
<majorAlarms>1</majorAlarms>
<managementStatus>UNKNOWN</managementStatus>
<manufacturerPartNrs>
<manufacturerPartNr>String value</manufacturerPartNr>
</manufacturerPartNrs>
<minorAlarms>1</minorAlarms>
<productFamily>String value</productFamily>
<reachability>UNKNOWN</reachability>
<softwareType>String value</softwareType>
<softwareVersion>String value</softwareVersion>
<warningAlarms>1</warningAlarms>
</devicesDTO>
</entity>
</queryResponse>
b) Get InventoryDetails: I just showing the udiDetails for the device I am performing the query on Device in order to get the udiSerdialNr_:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<queryResponse rootUrl="https://szier-m8-106.cisco.com/webacs/api/v1/data" requestUrl="https://szier-m8-106.cisco.com/webacs/api/v1/data/InventoryDetails/42" responseType="getEntity">
<entity url="https://szier-m8-106.cisco.com/webacs/api/v1/data/InventoryDetails/15" type="InventoryDetails" dtoType="inventoryDetailsDTO">
<inventoryDetailsDTO id="15" displayName="String value">
<udiDetails>
<udiDetail>
<description>String value</description>
<modelNr>String value</modelNr>
<name>String value</name>
<productId>String value</productId>
<udiSerialNr>String value</udiSerialNr>
<versionId>String value</versionId>
</udiDetail>
</entity>
</queryResponse>
I find both objects have same parameter: deviceId, how could I use it in order to include this information in the Device query? or if you have any advice please let me know.
Thank you.
Rose
10-05-2016 02:02 PM
There is no way to combine the two queries into one.
However, they are both enumerated with the same IDs; that is, api/v1/data/Devices/12345 is the same device as api/v1/data/InventoryDetails/12345. So you could query both API resources and correlate the data client-side.
10-05-2016 02:16 PM
Hello Spencer,
Thank you for your answer, they are using the same ID, I could use it to correlate the data, could you please let me know how could do it? I am newbie in API and I am trying to do it.
Thanks a lot.
10-05-2016 02:34 PM
The correlation is something you'd have to do client-side; you'd have to program your client to do it or configure your off-the-shelf solution.
The specifics all depend on the client that's interacting with the API, and whatever you're using to persist the data. For example, if I were in your spot and using a document store to persist the data, I'd probably concurrently fetch from both API resources, merge each entity together, and then shove that merged document into the store.
10-05-2016 03:04 PM
Thanks a lot Spencer!!! Your answers provided me a lot of useful tips and guidance in API.
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