Does the API allow me to search for all users where their department.description = A070301
An example of "">api.samanage.com/users.json" is below:
As far as I can see there's no way to filter on the department description from the users endpoint.
Filtering on sites and departments description isn't working for me either. So, you would need get a list of all the departments, then loop through all of them to find any that have that matching description, and then search for users with that department.
Here's an example of what that might look like in python
import requestsimport re# This reuses the TCP session for each request.samanage = requests.Session()auth_headers = {"X-Samanage-Authorization": "Bearer YourTokenHere"}samanage.headers.update(auth_headers)# Note this only grabs the first page. You'll need to decide how you want to handle pagination.response = samanage.get("https://api.samanage.com/departments.json")if not response.ok: response.raise_for_status()departments = response.json()matching_department_ids = []for department in departments: description = department.get("description", "") # This assumes the description is exactly "A070301". If you aren't familiar with rexex # use regex101's website to build the correct regex string match = re.search(r"A070301", description) if match: matching_department_ids.append(department["id"])# Again, this doesn't handle pagination. Python params argument would create a url like"# https://api.samanage.com/users.json?department[]=12345&department[]=67890response = samanage.get("https://api.samanage.com/users.json", params={"department": matching_department_ids})if not response.ok: response.raise_for_status()filtered_users = response.json()for user in filtered_users: print(user["id"], user["name"], user["email"])