08-05-2015 11:49 AM
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?
Solved! Go to Solution.
08-06-2015 01:31 PM
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!
08-06-2015 01:31 PM
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!
08-06-2015 01:38 PM
> 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.
08-06-2015 02:08 PM
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")
08-07-2015 05:35 AM
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.
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