0

ArcGIS Pro 3.1, Python 3.9

I'm using the ArcGIS Python API to connect to Portal (11.1) and AGOL to filter for deprecated items. According this reference doc, Item Fields can be passed to the query parameter. However, none of the parameter values return any values, e.g:

gis.content.search(query= 'contentStatus:deprecated') --> returns: []

screenshot

Am I missing something?

It works with other values, such as id:1234, or owner:my_username.


EDIT: Printing all properties shows the expected contentStatus property.

screenshot_item_properties

Similarly, using .contentStatus or .content_status also shows the correct value. https://developers.arcgis.com/python/latest/api-reference/arcgis.gis.toc.html#arcgis.gis.Item.content_status

screenshot_content_status_property

It seems iterating all item_id numbers is an option, though not ideal.

2
  • 1
    What happens if you get an item that you know is deprecated (eg, using item = gis.content.get(item_id) ) and then print all of that item's properties (eg, usingprint(json.dumps(dict(item), indent=4)) )? Please update your question post to include the results. Commented May 28 at 2:37
  • @SonofaBeach added. Item properties seem to contain the expected deprecated value. Commented May 28 at 15:58

1 Answer 1

1

Seems inefficient, but iterating all items is a possible solution.

# if content exceeds 10K items, advanced search with pagination is needed
all_content = gis.content.search(query='', max_items = 10000)

# list comprehension to get deprecated items via content status property
deprecated_items = [item for item in all_content if item.content_status == 'deprecated']

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.