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?
import os
from arcgis.gis import GIS
path = r'PATH'
KMLs = []
for root, dirs, files in os.walk(path):
for file in files:
if '.kml' in file or '.kmz' in file:
KMLs.append(os.path.join(root, file))
for KML in KMLs:
print(KML)
gis = GIS("https://ORG.maps.arcgis.com/", "USERNAME", "PASSWORD", verify_cert=False)
Items = []
for KML in KMLs:
kml_properties = {
'type': 'KML',
'typeKeywords': os.path.split(KML)[1]
}
data_file_location = KML
add_KML = gis.content.add(item_properties = kml_properties, data = data_file_location)
add_KML.share(everyone = True)
Items.append(add_KML)
Items
for item in Items:
print(item.title + ": " + "https://ORG.maps.arcgis.com/home/item.html?id=" + item.id)