Is there a way to categorize items through the API (to group categories)? I would like to set this as a property just like title, tags etc. Is this not yet implemented in the API for Python?
I tested the following code in Python API 1.5.0, it works.
from arcgis.gis import GIS gis=GIS(url="https://orgname.maps.arcgis.com",username="abc") # get the CategoryManager for this GIS cs=gis.admin.category_schema # get the item you want to work on item1=gis.content.get("<item ID>") # assign the item to the desired categories # you may need to create the categories first in AGOL cs.categorize_item(item1,['/Categories/People', '/Categories/Boundaries'])
I am not sure I understand the question. what do you mean "Group categories"? is it "Sub Categories"? If yes, I guess you can access sub categories the same way using the code provided. CategoryManager is where all the relevant functions are implemented.
Sorry if my question is unclear. There seems to be categories both at the organisation level and at group level - https://doc.arcgis.com/en/arcgis-online/share-maps/own-groups.htm. Your script access the category_schema at the organisation level (from the gis object) but can I access a similar schema from the group level? Right now, I manually categorized all items but would still like to be able to do it with the API...
Unfortunately I can't find any implementation of the group category in Python API. So it seems you have to use REST API to do it.
To list the the group content categories :
To update the group content categories :
Google "how to send http request using python" will get the coding part sorted for you.
This can be done with v1.7.1 now.
The Group class has a categories property, that gives you access to the CategorySchemaManager for that group.
Then you can use the .assign_to_items() method to assign group categories to items that belong to the group.
It looks like you should be able to do it with the standard Enterprise API with the assign_to_items() command.
That being said, I tried it with different json formats (categories and groupCategories - the second being how it actually is in the json for an item categorized into a group category vs what the example says) and it did not work (always returned "false" response).
Have you had any luck using the REST API? I have also been trying to categorize items into group categories in python.