When I run the script below to upload thousands of kmz files to my AGOL as kml they upload without a service url in item details. If I login to my account an use the add item tool to upload the files individual then a service url is generated. Any ideas?
<SPAN class="keyword token">import</SPAN> os
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis <SPAN class="keyword token">import</SPAN> GIS
path <SPAN class="operator token">=</SPAN> r<SPAN class="string token">'PATH'</SPAN> <SPAN class="comment token"># the folder where the .kml and .kmz files are stored</SPAN>
<SPAN class="comment token"># List all .kml and .kmz files in the folder</SPAN>
KMLs <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">for</SPAN> root<SPAN class="punctuation token">,</SPAN> dirs<SPAN class="punctuation token">,</SPAN> files <SPAN class="keyword token">in</SPAN> os<SPAN class="punctuation token">.</SPAN>walk<SPAN class="punctuation token">(</SPAN>path<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> file <SPAN class="keyword token">in</SPAN> files<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="string token">'.kml'</SPAN> <SPAN class="keyword token">in</SPAN> file <SPAN class="operator token">or</SPAN> <SPAN class="string token">'.kmz'</SPAN> <SPAN class="keyword token">in</SPAN> file<SPAN class="punctuation token">:</SPAN>
KMLs<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>join<SPAN class="punctuation token">(</SPAN>root<SPAN class="punctuation token">,</SPAN> file<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> KML <SPAN class="keyword token">in</SPAN> KMLs<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>KML<SPAN class="punctuation token">)</SPAN>
gis <SPAN class="operator token">=</SPAN> GIS<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"https://ORG.maps.arcgis.com/"</SPAN><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> verify_cert<SPAN class="operator token">=</SPAN><SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Add the .kml and .kmz files</SPAN>
Items <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">for</SPAN> KML <SPAN class="keyword token">in</SPAN> KMLs<SPAN class="punctuation token">:</SPAN>
kml_properties <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="string token">'type'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'KML'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'typeKeywords'</SPAN><SPAN class="punctuation token">:</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN>KML<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="punctuation token">}</SPAN>
data_file_location <SPAN class="operator token">=</SPAN> KML
<SPAN class="comment token"># Add item to portal</SPAN>
add_KML <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> kml_properties<SPAN class="punctuation token">,</SPAN> data <SPAN class="operator token">=</SPAN> data_file_location<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Share item to everyone</SPAN>
add_KML<SPAN class="punctuation token">.</SPAN>share<SPAN class="punctuation token">(</SPAN>everyone <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
Items<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>add_KML<SPAN class="punctuation token">)</SPAN>
Items
<SPAN class="keyword token">for</SPAN> item <SPAN class="keyword token">in</SPAN> Items<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">.</SPAN>title <SPAN class="operator token">+</SPAN> <SPAN class="string token">": "</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"https://ORG.maps.arcgis.com/home/item.html?id="</SPAN> <SPAN class="operator token">+</SPAN> item<SPAN class="punctuation token">.</SPAN>id<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></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>