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.
The following code should do the trick if you are using the latest Python API, version 1.5.0.
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis <SPAN class="keyword token">import</SPAN> GIS gis<SPAN class="operator token">=</SPAN>GIS<SPAN class="punctuation token">(</SPAN>url<SPAN class="operator token">=</SPAN><SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fwww.arcgis.com" target="_blank">https://www.arcgis.com</A><SPAN>"</SPAN></SPAN><SPAN class="punctuation token">,</SPAN>username<SPAN class="operator token">=</SPAN><SPAN class="string token">"username"</SPAN><SPAN class="punctuation token">)</SPAN> item1<SPAN class="operator token">=</SPAN>gis<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"<item ID>"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># content_status accept "authoritative","deprecated" or None</SPAN> item1<SPAN class="punctuation token">.</SPAN>content_status<SPAN class="operator token">=</SPAN><SPAN class="string token">"authoritative"</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Thank you very much for the answer. I just needed to check it, but it was correct.
Best regards,
Morten
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.
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...
<SPAN class="keyword token">import</SPAN> arcgis <SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis <SPAN class="keyword token">import</SPAN> GIS <SPAN class="keyword token">import</SPAN> requests gis <SPAN class="operator token">=</SPAN> GIS<SPAN class="punctuation token">(</SPAN>None<SPAN class="punctuation token">,</SPAN><SPAN class="string token">'username'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'password'</SPAN><SPAN class="punctuation token">)</SPAN> featureLayerItem <SPAN class="operator token">=</SPAN> gis<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Your item id here'</SPAN><SPAN class="punctuation token">)</SPAN> r <SPAN class="operator token">=</SPAN> requests<SPAN class="punctuation token">.</SPAN>post<SPAN class="punctuation token">(</SPAN><SPAN class="string token"><SPAN>'</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F" target="_blank">https://</A><SPAN>{0}/sharing/rest/content/items/{1}/setContentStatus'</SPAN></SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Your org domain here'</SPAN><SPAN class="punctuation token">,</SPAN>featureLayerItem<SPAN class="punctuation token">.</SPAN>id<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> data<SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="string token">'status'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'org_authoritative'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'clearEmptyFields'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'false'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'f'</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">'json'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'token'</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">'Your token here'</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
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.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.