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?
Hi Morten,
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.
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...
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
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 tested the following code in Python API 1.5.0, it works.
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis <SPAN class="keyword token">import</SPAN> GIS gis<SPAN class="operator token">=</SPAN>GIS<SPAN class="punctuation token">(</SPAN>url<SPAN class="operator token">=</SPAN><SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Forgname.maps.arcgis.com" target="_blank">https://orgname.maps.arcgis.com</A><SPAN>"</SPAN></SPAN><SPAN class="punctuation token">,</SPAN>username<SPAN class="operator token">=</SPAN><SPAN class="string token">"abc"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># get the CategoryManager for this GIS</SPAN> cs<SPAN class="operator token">=</SPAN>gis<SPAN class="punctuation token">.</SPAN>admin<SPAN class="punctuation token">.</SPAN>category_schema <SPAN class="comment token"># get the item you want to work on</SPAN> item1<SPAN class="operator token">=</SPAN>gis<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"<item ID>"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># assign the item to the desired categories</SPAN> <SPAN class="comment token"># you may need to create the categories first in AGOL </SPAN> cs<SPAN class="punctuation token">.</SPAN>categorize_item<SPAN class="punctuation token">(</SPAN>item1<SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'/Categories/People'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'/Categories/Boundaries'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.