1

I need to create a Python script to upload an MXD to AGOL. I have created an script in arcpy to create a service definition file (*.sd) from the mxd. I have not been able to upload the sd to AGOL unless ArcMap is open. I use the following code:

arcpy.SignInToPortal_server("AGOL_USER", "AGOL_PASS", "http://www.arcgis.com/")
arcpy.UploadServiceDefinition_server(sd, "My Hosted Services", service)

I get the following error:

arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Server: Dataset My Hosted Services does not exist or is not suppoted
Failed to execute (UploadServiceDefinition).

I have been able to upload the service document file using ArcGIS API for Python:

gis = GIS("https://XXXX.maps.arcgis.com", "AGOL_USER", password)
item = gis.content.add({}, "XXX.sd")
published_item = item.publish(overwrite=True)

a) How can I upload the service definition file to AGOL using arcpy? The script needs to be run scheduled, so I cannot have ArcMap open

b) Would be posible to merge arcpy code with ArcGIS API for Python?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.