For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

tatmotiv's avatar
tatmotiv
Icon for Cirrostratus rankCirrostratus
Dec 10, 2015

combine filter and expandSubcollections in REST query with curl

Following Jason's great article at https://devcentral.f5.com/articles/demystifying-icontrol-rest-part-3-how-to-pass-query-parameters-and-tmsh-options I'm trying to use some of the built in features of the REST API. To be more specific, I'm trying to get all ltm pools of a specific partition with expanded subCollections, thus listing all pool members currently in use. Therefore, I was planning to combine $filter+eq+partitionname and expandSubcollections=true in one query. However, I cannot figure out how to combine both of them...

 

This works:

 

curl -sk -u admin:password https://mymachine/mgmt/tm/ltm/pool?\$filter=partition%20eq%20mypartition

...so does this:

 

curl -sk -u admin:password https://mymachine/mgmt/tm/ltm/pool?expandSubcollections=true

But THIS does not work - it does not expand the members subcollection plus it creates some malformed JSON return string (when piping the return through json_xs, it gives back "malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "(end of string)") at /usr/bin/json_xs"):

 

curl -sk -u admin:password https://mymachine/mgmt/tm/ltm/pool?\$filter=partition%20eq%20mypartition&expandSubcollections=true

Neither does THIS work...

 

curl -sk -u admin:password https://mymachine/mgmt/tm/ltm/pool?expandSubcollections=true&\$filter=partition%20eq%20mypartition

... it returns:

 

If '$filter=partition%20eq%20mypartition' is not a typo you can run the following command to lookup the package that contains the binary:
command-not-found $filter=partition%20eq%20mypartition
-bash: $filter=partition%20eq%20mypartition: command not found
{"code":400,"message":"Query parameter $expandSubcollections is invalid.","errorStack":[]}

The last one seems to be a matter of escape sequences - somehow bash is interpreting the $filter part as a command on its own. Can anybody please point out how to combine those query parameters into one valid query? Many thanks in advance!

 

1 Reply

  • Looks like bash doesn't like the ampersand. Try this:

    curl -sk -u admin:admin \ https://ip/mgmt/tm/ltm/pool\$filter=partition+eq+mypartition\&expandSubcollections=true

    BTW, I highly recommend Chrome's Advanced REST Client for test purposes as well