cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1183
Views
1
Helpful
4
Replies

exportDevices

smp
Level 4
Level 4

Hello! I'm new to the PI API, just starting to fumble my way through doing something useful. At the moment, I am trying to use the GET Export Devices operation on all my devices. The API guide instructs me to use the URL '/webacs/api/v1/op/devices/exportDevices'. But when I try this without any request parameters (as shown in the documentation examples), I get none. However, I can successfully get a device export if I add an ipAddress parameter to the query. The documentation clearly states that the three available parameters are /optional/, so it's unclear to me why no devices are output without them.

I don't have a development background, so perhaps I don't understand the API documentation. Am I doing something wrong?

1 Accepted Solution

Accepted Solutions

Spencer Zier
Cisco Employee
Cisco Employee

You will have to specify one of the three parameters.  It is a little confusing that they are marked as optional, but the API framework that we use only allows us to mark them as either "optional" or "required".  Since you're not required to send all three for any single request, it would also be confusing to mark all of them as required

We tried to explain in the description of the resource:

It accepts three parameters: ipAddress, groupId or groupPath. If no parameters are specified, no devices will be exported.


I apologize for the confusion, I hope that clears it up.  If you need anything else please let us know!

View solution in original post

4 Replies 4

Spencer Zier
Cisco Employee
Cisco Employee

You will have to specify one of the three parameters.  It is a little confusing that they are marked as optional, but the API framework that we use only allows us to mark them as either "optional" or "required".  Since you're not required to send all three for any single request, it would also be confusing to mark all of them as required

We tried to explain in the description of the resource:

It accepts three parameters: ipAddress, groupId or groupPath. If no parameters are specified, no devices will be exported.


I apologize for the confusion, I hope that clears it up.  If you need anything else please let us know!

> It accepts three parameters: ipAddress, groupId or groupPath. If no parameters are specified, no devices will be exported

Yes, I noticed that, which is why I even /attempted/ to add the ipAddress parameter at all. Thanks for adding that nugget.

Is there any single parameter I can add that would return /all/ devices? I think I tried .full=true, but that didn't work.

It's kind of a hack (because this API resource was not written to support exporting all of the devices in the system) but you can use this:

webacs/api/v1/op/devices/exportDevices?groupPath=startsWith("Device%20Type")

Ugh. I guess the right thing to do is generate a list of IPs from /webacs/api/v1/data/Devices and loop through it.

Thanks again for the feedback, it's difficult to find a resource who is knowledgeable about the API. I'll be posting more soon, I'm sure.