Select to view content in your preferred language

Searching for items marked as authoritative

1396
4
11-08-2024 04:32 AM
RobGordon1
Emerging Contributor

I am using the ArcGIS python API as I would like to count items in my agol that are marked as authoritative. I have been able to search by owner and type but I cannot get the contentStatus search term to work at all. I have read the documentation over and over and I just can't figure out what is wrong. 

auth_items = gis.content.search(query='contentStatus:public_authoritative', max_items=100)
 
auth_no = len(auth_items)
print(auth_no)
 
Thanks!
0 Kudos
4 Replies
CodyPatterson
MVP Regular Contributor

Hey @RobGordon1 

Could you try to search for this here:

auth_items = gis.content.search(query='contentStatus:authoritative', max_items=100)

I think it falls into a general category of authoritative, I've seen this here too:

CodyPatterson_0-1731070192253.png

 

Cody

0 Kudos
RobGordon1
Emerging Contributor

Thanks @CodyPatterson but... I have answered my own question.... 

So this page Search reference | ArcGIS REST APIs | ArcGIS Developers has the term contentStatus which does not work. But this non python page on advanced search has the term contentstatus . This does work! 😂😭

To add to the confusion I have to use contentstatus:public_authoritative (or org_authoritative) as authoritative alone is not a recognised value. This is as written on the API page next to contentStatus.

My status is now: 😑

CodyPatterson
MVP Regular Contributor

Hey @RobGordon1 

Definitely quite a lot of strangeness! I seem to be left as that status quite often when attempting to read through some of the documentation unfortunately.

Cody

0 Kudos
Abe_808
New Contributor

A couple of years too late, but hopefully valuable to others.

Per Copilot:

  • "authoritative" is often used in some older examples.
  • "org_authoritative" is what many current orgs actually return for items marked authoritative within that organization.
from arcgis.gis import GIS
import pyodbc

# 1. Reuse your ArcGIS Pro login (no credentials in code)
gis_portal = GIS("pro")

# 2. Types we consider "webapps" for the techfolio
types = [
    "Web Mapping Application",
    "Dashboard",
    "Web Experience"
]

all_webapps = []

for t in types:
    # Exclude items owned by esri_apps at the search stage
    # You can add more owners later if needed: 'AND -owner:esri'
    items = gis_portal.content.search(
        query='-owner:esri_apps',   # exclude Esri's org apps
        item_type=t,
        max_items=1000
    )
    all_webapps.extend(items)

print(f"Total webapps found (owner != esri_apps): {len(all_webapps)}")

# 3. Filter to authoritative only using the Item.content_status property
authoritative_apps = []

for item in all_webapps:
    status = (getattr(item, "content_status", "") or "").strip().lower()
    # Debug – optional: see status for your items
    print(item.title, "| owner:", item.owner, "| status:", repr(status))

    if status == "org_authoritative":
        authoritative_apps.append(item)

print(f"Authoritative webapps (excluding owner esri_apps): {len(authoritative_apps)}")

 

 

 

0 Kudos