REST API get facts search filter

Hi,

It's trivial to do a request with curl or another rest-client to get
the facts of a host.

This works:
http://foremanapi/api/hosts/hostnametoquery/facts?page=2

But when I try
http://foremanapi/api/hosts/hostnametoquery/facts?search=augeasversion

(or any other fact)
The result is empty

What am I doing wrong (I don't have that much rest experience)

Sincerely, Pieter

If I recall, then you have to get all the facts as a JSON hash, and then
get the one you want out of the hash, so something like:

curl --user 'admin:changeme' -k -H "Content-Type: application/json" '
http://topaz/api/hosts/topaz.elysium.emeraldreverie.org/facts'

{"topaz.elysium.emeraldreverie.org":{"swapfree_mb":"0.00","swapsize_mb":"0.00","swapfree":"0.00
MB","swapsize":"0.00
MB","macaddress_wlan0":"00:15:af:ee:d8:f0","macaddress_eth0":"00:22:15:97:2a:f0","macaddress":"00:22:15:97:2a:f0","bios_release_date":"03/17/2009","physicalprocessorcount":"1","augeasversion":"1.0.0","ipaddress_lo":"127.0.0.1","uniqueid":"14ac140a","blockdevice_sdb_size":"16139354112","facterversion":"1.7.0","ipaddress":"172.20.10.20","ipaddress_eth0":"172.20.10.20","uptime_seconds":"1877312","bios_version":"1903","processorcount":"2","rubyversion":"2.0.0"}}

You can also search for facts on all hosts, which might be an indirect
approach:

curl --user 'admin:changeme' -k -H "Content-Type: application/json" '
http://topaz/api/hosts?search=facts.augeasversion+~++0.10.0'
[{"host":{"name":"anubis.elysium.emeraldreverie.org
","id":13,"hostgroup_id":3,"operatingsystem_id":2}},{"host":{"name":"
minerva.elysium.emeraldreverie.org
","id":9,"hostgroup_id":7,"operatingsystem_id":2}},{"host":{"name":"
mythbox.elysium.emeraldreverie.org
","id":10,"hostgroup_id":3,"operatingsystem_id":2}}]

Note that the search string in the second example is the same as in the Web
UI, so you can test your searches there before trying the API.

Hope that helps,
Greg

··· On 15 May 2013 09:53, Pieter Baele wrote:

Hi,

It’s trivial to do a request with curl or another rest-client to get
the facts of a host.

This works:
http://foremanapi/api/hosts/hostnametoquery/facts?page=2

But when I try
http://foremanapi/api/hosts/hostnametoquery/facts?search=augeasversiohttp://foremanapi/api/hosts/hostnametoquery/facts?search=augeasversion