I am using the SOFTLAYER REST API in order to get the virtual machine list then select one of the results and get more details only about the selected machine.
I used this URL to get the machine details by hostname but i get all the machines as result and not the one i selected
URL :
https://api.softlayer.com/rest/v3.1/SoftLayer_Account/getVirtualGuests.json?objectMask=mask[id,hostname,fullyQualifiedDomainName,provisionDate,powerState,operatingSystem[id,passwords[password,username],softwareDescription[longDescription]]]&objectFilter={"hostname":{"operation":"SLRAMONT02"}}
What should i do the get the wright result?
I used python with the same url and I get the expected result but after a debug I found that python is converting the JSON to XML and using the SOAP API.
I'm not planning to use the python API but the JAVA. Can I make the same request using JAVA API?
This basically was answered here: Softlayer filtering not working.
On your case you need to use following filter:
objectFilter={"virtualGuests":{"hostname":{"operation":"SLRAMONT02"}}}
Also I recommend to review: How to use object filter with softlayer rest api?
Unfortunately object-filters is not supported yet by Softlayer-Java API, this is commented here:
Object Filters in Softlayer in Java
https://github.com/softlayer/softlayer-java/issues/30
If you really need to use object-filters in Java, you can try by using RESTFul, there are some RESTful examples in the following links.
https://www.mkyong.com/webservices/jax-rs/restfull-java-client-with-java-net-url/ https://www.mkyong.com/webservices/jax-rs/restful-java-client-with-apache-httpclient/