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 GISgis=GIS(url="https://orgname.maps.arcgis.com",username="abc")# get the CategoryManager for this GIScs=gis.admin.category_schema# get the item you want to work onitem1=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'])
Thank you for the answer. It looks like the Category_schema is the schema for the entire GIS organisation. In this case I am using Group categories. How to access them?
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.
CategoryManager — arcgis 1.5.0 documentation
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 :
Group Category Schema—ArcGIS REST API: Users, groups, and content | ArcGIS for Developers
To update the group content categories :
Update Group Items with Content Categories—ArcGIS REST API: Users, groups, and content | ArcGIS for Developers
Google "how to send http request using python" will get the coding part sorted for you.
Thank you. I will try that way.
Retrieving data ...