Is there a way to access and set the property "authoritative" on data items in AGOL to "Yes" through the API or has this not been implemented yet? I am bulk creating "authoritative" services with a script.
Solved! Go to Solution.
The following code should do the trick if you are using the latest Python API, version 1.5.0.
from arcgis.gis import GIS
gis=GIS(url="https://www.arcgis.com",username="username")
item1=gis.content.get("<item ID>")
# content_status accept "authoritative","deprecated" or None
item1.content_status="authoritative"
Hello Morten,
I don't think the API support making items "authoritative" yet. But you can use the API to get the id's then use the requests module to hit the endpoint and make the item authoritative. Here is an example...
import arcgis
from arcgis.gis import GIS
import requests
gis = GIS(None,'username', 'password')
featureLayerItem = gis.content.get('Your item id here')
r = requests.post('https://{0}/sharing/rest/content/items/{1}/setContentStatus'.format('Your org domain here',featureLayerItem.id), data= {'status': 'org_authoritative','clearEmptyFields': 'false', 'f':'json', 'token':'Your token here'})
You will need to put in your organizations domain and also you will need to get a token so that you can pass it with the request. This documentation shows how you can get a token using python.
The following code should do the trick if you are using the latest Python API, version 1.5.0.
from arcgis.gis import GIS
gis=GIS(url="https://www.arcgis.com",username="username")
item1=gis.content.get("<item ID>")
# content_status accept "authoritative","deprecated" or None
item1.content_status="authoritative"
If this is the answer, can you please mark it as the "correct answer"? by doing so it will appear at the top and help people with same question to find the correct answer quicker. Thanks.
Thank you very much for the answer. I just needed to check it, but it was correct.
Best regards,
Morten