Hey, is there way to retrieve this payload with th...
# fleet
j
Hey, is there way to retrieve this payload with the API without using the webhook feature? Specifically, can I retrieve a policy with the failing devices below it one JSON with an API call?
Copy code
{
  "timestamp": "0000-00-00T00:00:00Z",
  "policy": {
    "id": 1,
    "name": "Is Gatekeeper enabled?",
    "query": "SELECT 1 FROM gatekeeper WHERE assessments_enabled = 1;",
    "description": "Checks if gatekeeper is enabled on macOS devices.",
    "author_id": 1,
    "author_name": "John",
    "author_email": "john@example.com",
    "resolution": "Turn on Gatekeeper feature in System Preferences.",
    "passing_host_count": 2000,
    "failing_host_count": 300
  },
  "hosts": [
    {
      "id": 1,
      "hostname": "macbook-1",
      "url": "<https://fleet.example.com/hosts/1>"
    },
    {
      "id": 2,
      "hostname": "macbbook-2",
      "url": "<https://fleet.example.com/hosts/2>"
    }
  ]
}
g
Hey @JJ, Might filter
policy_id
on the hosts endpoint. Not sure if this is exactly what looking at for the data. example-
Copy code
curl -LSs -H 'Authorization: Bearer <APITOKEN>' -H 'Content-Type:application/json' '<https://dogfood.fleetdm.com/api/latest/fleet/hosts?policy_id=2261&policy_response=failing>'
j
Yep - that's the info I'm after. Cheers, Grant 👍