Select to view content in your preferred language

Not Able to Get Portal Null Contents Item ID using ArcGIS API for Python

333
4
07-29-2024 12:47 PM
BHK
by
Occasional Contributor

 

Using ArcGIS Enterprise 10.9.1 Sharing API I am able to see some `null` type items in my portal

BHK_0-1722281999789.png

but when I try to get these items through ArcGIS API for Python like this

 

username = "PortalUserXXX"
item_type = 'null'  # This represents null type

# Search for items
items = gis.content.search(query=f'owner:{username} AND type:"{item_type}"', max_items=1000)

# Print the retrieved items
for item in items:
    print(f'Title: {item.title}, ID: {item.id}, Type: {item.type}')

 

 

I am not getting anything in return.

I even tried this

 

username = "PortalUserXXX"
item_type = None  # This represents null type

 

 

and same result! I tried this

 

username = "PortalUserXXX"
item_type = ''  # This represents null type

 

which is returning all items BUT not the Null one! Can you please let me know what I am doing wrong and what I am missing here?

 

 

0 Kudos
4 Replies
Brian_Wilson
Honored Contributor

I expect something with type set to null to be broken.

Have you tried accessing it with the id, since you appear to have that?

id = "SET THIS TO AN ID"
item = gis.content.get(id)
print(f'Title: {item.title}, ID: {item.id}, Type: {item.type}')

 

And also maybe this would work?

items = gis.content.search(query=f'owner:{username}', max_items=1000)
for item in items:
  if not item.type:
    print(f'Title: {item.title}, ID: {item.id}, Type: {item.type}')
0 Kudos
BHK
by
Occasional Contributor

Hi Braian 

Thanks for reply. on first code 

id = "647f546a463e474e9abf0211f4d4ccfe"
item = gis.content.get(id)
print(f'Title: {item.title}, ID: {item.id}, Type: {item.type}')

 

I am getting this error message:  Unable to find ItemInfo for item '647f546a463e474e9abf0211f4d4ccfe' (Error Code: 500)

your second submitted  snippet also is not returning anything 

 

0 Kudos
Brian_Wilson
Honored Contributor

It's just a broken service. If you can look in your Portal server "contents/items" folder, you can find the folder that has the name matching the ID and look inside.  For example on my server it's in C:\arcgis\arcgisportal\content\items.

There will be a folder there for each item and you could open the folder and look inside. For instance on my server I could look in folder "b87919419f6c4cd4a1580085f58b0c8f" and for this service there is a folder "esriinfo" and in there is "iteminfo.json" and I could dump the contents of that file in a readable way and I'd see this

$ python -m json.tool < iteminfo.json
{
    "culture": "en-US",
    "name": "Clatsop_County_Locator",
    "guid": "",
    "catalogPath": "",
    "snippet": "Locator based on E911 address points, points of interest, parcels, and roads",
    "description": "Locator based on E911 address points, points of interest, parcels, and roads",
    "summary": "Locator based on E911 address points, points of interest, parcels, and roads",
    "title": "Clatsop_County_Locator",
    "tags": [
        "Clatsop",
        "County",
        "address",
        "locator",
        "geocode"
    ],
    "type": "Geocoding Service",
    "typeKeywords": [
        "Tool",
        "Service",
        "Geocoding Service",
        "Locator Service",
        "ArcGIS Server"
    ],
    "thumbnail": "",
    "url": "",
    "minScale": 0,
    "maxScale": 0,
    "spatialReference": "",
    "accessInformation": "",
    "licenseInfo": ""
}

 

In your case, well, it might tell you all about a service that used to work but is now broken, and probably you will have to delete the item folder and then reindex your Portal to make it go away.

But if you are not comfortable doing that then you should put in a request to Esri help desk instead of trusting some random guy on Community who is retiring in less than 3 days. LOL (YAY YAY)

 

0 Kudos
Brian_Wilson
Honored Contributor

I should add, if you cannot find the item folder at all or the folder is empty then you can probably jump right to part two, reindex your portal. It is relatively harmless to do but makes the Portal unavailable for a few minutes.

 

To reindex you log into your Portal Admin site, go to System, Indexer, and click Reindex.

The portal admin site is found at the same URL as the home page for your Portal but you replace "home" with "portaladmin" for example

https://bhk.somewhere.com/portal/portaladmin

0 Kudos