So, the first thing you'll need is the policy ID: If you go to Systems Manager > Policies and click on the policy that you want to use as a criteria, you'll now be able to get the policy ID from the URL:
https://XXXX.meraki.com/General/n/XXXXXXX/manage/configure/pcc_security_policy#security_policy=68116...
So, now that we have the ID, we can go to the API call:
https://api.meraki.com/api/v0/networks/{{NetworkID}}/sm/devices?fields=ip&scope=withAll,auto:security_policy_uncompliant681169443639788406
If you don't know your network (or Org) IDs, you'll need to do the following two API calls:
Orgs
--header 'X-Cisco-Meraki-API-KEY: {{APIKEY}}'
Returns:
This brings back a list of your orgs. You probably only have the one. Grab the id. Then, we....
Networks
This will bring back a list of networks.
[ { "id": "L_123456", "organizationId": "2930418", "name": "Long Island Office", "timeZone": "America/Los_Angeles", "tags": [ "tag1", "tag2" ], "productTypes": [ "appliance", "switch", "wireless" ], "enrollmentString": "long-island-office", "notes": "Combined network for Long Island Office" } ]
Grab your network id