I have had this work regularly before but for some reason, since the update to 10.5 I think but I cant say for sure, the UploadServiceDefinition tool isn't working consistently when I want to send something to AGOL. I haven't changed anything in the code and everything runs fine until that last step. I have tried logging in to AGOL in ArcMap and saving the map docs, signing in and leaving ArcMap open, and even running the script from within ArcMap while signed in. I just checked help(arcpy.UploadServiceDefinition_server) to make sure the docs didn't change at 10.5 without me noticing. server_type is set to 'MY_HOSTED_SERVICES' when creating the draft definition. It worked a couple weeks ago but now isnt.. Any ideas?
arcpy.UploadServiceDefinition_server(in_sd_file = finalSD,
in_server = "My Hosted Services",
in_service_name = mapDoc,
in_cluster = "",
in_folder_type = "EXISTING",
in_folder = "OpenData")
Gives me an error:
Failed to execute. Parameters are not valid.
ERROR 000732: Server: Dataset My Hosted Services does not exist or is not supported
Failed to execute (UploadServiceDefinition).