09-28-2016 06:38 AM
I have a list of IPs that I want to delete, and I'm trying to use the new POST devices/removalJob API. But I am having a little trouble with the format of the JSON data structure. The API documentation examples don't include structures with multiple entries, so it's unclear to me how they should look.
I've tried a couple of formats, but this is the one one I've had any success with:
{
"removalJobParamsDTO":{
"ipAddressList":{
"ipAddressList":{
"address":"10.143.128.21",
"address":"10.143.128.22",
"address":"10.143.128.23"
}
}
}
}
But even in this case the job is created, but only the last device in the list is deleted. Is JSON format correct for this data structure?
Solved! Go to Solution.
09-28-2016 10:05 AM
This will get you what you're looking for.
{ "removalJobParamsDTO" : { "ipAddressList" : { "ipAddressList" : [{ "address" : "10.1.2.3" },{ "address" : "10.7.8.9" }] } } }
09-28-2016 10:05 AM
This will get you what you're looking for.
{ "removalJobParamsDTO" : { "ipAddressList" : { "ipAddressList" : [{ "address" : "10.1.2.3" },{ "address" : "10.7.8.9" }] } } }
09-28-2016 12:36 PM
I will give this a try, thank you!
Some documentation feedback for your consideration...all the sample input code I've seen in the API documentation only references a single object - the POST devices/removalJob is an example. As my question demonstrates, there is a little additional syntax that must be inferred if you need to go beyond the API example. It would be helpful to us less-experienced programmers if those examples included multiple objects instead of just one.
Thanks again!
09-28-2016 01:21 PM
Yeah, fair point. Part of this is the flawed behavior of the v1 JSON provider; it should always treat ipAddressList as an array, even if it only has one member. That broken JSON provider is used to generate the samples for most of the documentation pages (presently, the only exceptions are for the v2 Clients and ClientDetails resources). I'll add a story to our backlog to change the generated samples for v2+. I think we'll leave v1 as it is, because either way, the sample won't be totally accurate; because if we have multiple elements in an array, it'll show it as a JSON array, but if the user gets a response with only one element, it'll come back as a JSON object.
We have some changes coming to the documentation in Prime Infrastructure 3.2 that should make versioning clearer. One of those changes is that every resource available in API v2, even if there were no changes for that specific resource in v2, will have a v2 page that uses the v2 JSON provider for its samples. You'll also be able to tell at a glance which resources have (potentially backwards incompatible) changes in an API version. Here's a sneak peak
Note that Client Details has a deep blue link for both v1 and v2, indicating that major changes were in each API version, but Client Counts and Client Sessions do not, indicating no major changes were made in v2, but they are still available in that version.
09-29-2016 06:51 AM
With your help, I was able to make the data structure and the deletes were successful. Thanks again very much for your help on this one - not sure I would have been able to figure it out on my own.
{
"removalJobParamsDTO" : {
"ipAddressList" : {
"ipAddressList" : [
{
"address" : "10.1.2.3"
},
{
"address" : "10.1.2.4"
},
{
"address" : "10.1.2.5"
}
]
}
}
}
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