ldanielw1 ldanielw1 - 2 months ago 12
reST (reStructuredText) Question

Using objectFilter to limit output of Softlayer's REST APIs?

I am trying to curl the list of images that I have available on Softlayer. My current curl command is:

curl 'https://USERNAME:API_KEY@api.softlayer.com/rest/v3/SoftLayer_Account/getBlockDeviceTemplateGroups.xml?objectMask=filteredMask\[id,name\]&objectFilter=\{"id":\{"operation":111111\}\}'`


But it doesn't work. The
objectMask
works, but the
objectFilter
seems to be letting everything through, and I still see every image (not only the one whose id is
111111
). Am I structuring my URL wrong at the end...?

Answer

This is the structure that you need to send:

curl "https://USERNAME:API_KEY@api.softlayer.com/rest/v3/SoftLayer_Account/getBlockDeviceTemplateGroups.xml?objectFilter={"blockDeviceTemplateGroups":{"id":{"operation":"111111"}}}&objectMask=id;name"

Unfortunately, it's necessary to escape the special characters using cURL, so you can send this ( object filter is encoding):

curl "https://USERNAME:API_KEY@api.softlayer.com/rest/v3/SoftLayer_Account/getBlockDeviceTemplateGroups.xml?objectFilter=%7B%22blockDeviceTemplateGroups%22%3A%7B%22id%22%3A%7B%22operation%22%3A%22111111%22%7D%7D%7D&objectMask=id;name"

Replace: USERNAME, API_KEY and 111111

e.g:

%22%3A%22111111%22%7D%7D%7D

References:

Comments