Hello, I'm trying to assign users that currently don't have categories new categories. I found this command screenshotted below in the docs (https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.UserManager).
The docs says the categories property can be used to get or set categories. Right now, I'm able to get a user category with this code:
all_users = gis.users.search(query='*', max_users=10)
for user in all_users:
category = user.categories
print(category)
However, I'm trying to set a user's category and my code is:
index = 0
for user in all_users:
user.categories = categories[index] # where categories is a list of lists, each nested list contains the corresponding user's new categories
++index
Nothing's happening to the user's category in ArcGIS Online when I run my code and I was wondering if anyone has had experience setting user categories with Python?
Thank you!
Solved! Go to Solution.
I believe categories only supports getting the property for user objects. You can set a user's category using the update() method.
I believe categories only supports getting the property for user objects. You can set a user's category using the update() method.
Thanks Peter, I'll give this a try!
Thanks Peter, I was having some issues with my arcgis version but once I updated it, I could use the update() method and successfully assigned categories!
Got it to apply finally. Here is what worked for me using the user.update()
user.update(categories = ["/Categories/States/Colorado"])
I was trying to apply a category that was nested I suppose...
When I try to use the same code, I get an error that categories isn't a recognized argument for the update() method. But other arguments like description, name, etc. work for me.