Hello - does anyone know how to set the content status on an item? Currently, the api will allow you to read the content status property, but there seems to be no way to set the content status. Something like:
portItem.update(item_properties={'content_status' : 'org_authoritative'})
would be ideal but 'content_status is not a property that can be set as part of item_properties, even as the json return does show content_status as contentStatus.
Solved! Go to Solution.
Hi,
All you have to do is the following:
portItem.content_status = 'authoritative'
Hi,
All you have to do is the following:
portItem.content_status = 'authoritative'
Thanks Lorne, yes that did it. 'org_authoritative' for portal. I thought I tried that first thing, but sadly the api documentation isn't as intuitive as maybe it should be. If interested, you can follow the content_status property setting with an Item.protect(enable=False) to remove delete protection, as I've been tripped up many times by having a layer set with delete protection . . .
found this super helpful article today by one of our Esri Community's newest MVPs, @Clubdebambos !
from the Esri docs:
Yes, I've been doing this for about 5 years now:
gis = GIS("https://yourorg.maps.arcgis.com/", "username", "pw")
try:
pubGroups = gis.groups.search(query='title:Some Group Title', max_groups=1000)
for pubGroup in pubGroups:
#print (pubGroup.title)
if (pubGroup.title == 'Some Group Title Layers Group'):
print (pubGroup.title)
items = pubGroup.content()
#print (items)
for item in items:
#print(item.name)
item.content_status = 'authoritative'
item.protect(enable=False)
#print(item.content_status)
message = message + "\n" + (pubGroup.title) + " Itens Sucessfully Reauthorized"
except Exception:
# If an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
e = sys.exc_info()[1]
print(e.args[0])
print ("Line %i" % tb.tb_lineno)
message = message + "\n" + "Line %i" % tb.tb_lineno
message = message + "\n" + str(e
In this way, you can just loop through your groups and the items in each group and set its content status and its protect status. I do this because each week as my collaborated layers sync by reference from portal to arcgis online, I need to re-authorize the layers.
More importantly though, for the layers in the workspace collaborations to sync without fail I need to remove the delete protect status....
awesome, nice work. thanks for marking a solution!