Hello,
I would like the ability to add or update a non-spatial item like a pdf from my computer to My Content in AGOL through a python script. We have an agol organizational account, but not arcgis enterprise. Does anyone know if this is possible?
Jake Skinner
The following code snippet worked for me:
<SPAN class="keyword token">from</SPAN> IPython<SPAN class="punctuation token">.</SPAN>display <SPAN class="keyword token">import</SPAN> display <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> os gis <SPAN class="operator token">=</SPAN> GIS<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%2Fwww.arcgis.com" target="_blank">https://www.arcgis.com</A><SPAN>"</SPAN></SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"MyUsername"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"MyPassword"</SPAN><SPAN class="punctuation token">)</SPAN> pdfdata <SPAN class="operator token">=</SPAN> <SPAN class="string token">"C:\\SomePath\\SomeFolder\\SomeFile.pdf"</SPAN> pdfprop <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="string token">'title'</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">'something'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'description'</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">'this is a thing'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'tags'</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">'tag'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'type'</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">'PDF'</SPAN><SPAN class="punctuation token">}</SPAN> pdf Doc <SPAN class="operator token">=</SPAN> gis<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>add<SPAN class="punctuation token">(</SPAN>item_properties <SPAN class="operator token">=</SPAN> pdfprop <SPAN class="punctuation token">,</SPAN> data <SPAN class="operator token">=</SPAN> pdfdata<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>
I used this same script to upload a kml file but noticed when I do so it does not generate a Data Source URL in the item properties. Any ideas?
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.