Mark data item as "Authoritative" with API for Python

1251
4
Jump to solution
08-24-2018 02:22 AM
MortenBjerrum1
Esri Contributor

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.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
simoxu
by MVP Regular Contributor
MVP Regular Contributor

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"‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

4 Replies
MunachisoOgbuchiekwe
New Contributor III

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.

simoxu
by MVP Regular Contributor
MVP Regular Contributor

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"‍‍‍‍‍‍‍‍‍‍‍‍‍‍
simoxu
by MVP Regular Contributor
MVP Regular Contributor

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.

0 Kudos
MortenBjerrum1
Esri Contributor

Thank you very much for the answer. I just needed to check it, but it was correct. 

Best regards,

Morten

0 Kudos