Python and Publishing to AGO for Organisations and My Hosted Services does not exist

Discussion created by timmerspk on Mar 14, 2013
Latest reply on Dec 5, 2017 by nathanheick@lacsd.org
I've got a bit of python that is publishing (or rather overwriting) data regularly to AGO and it works while ArcMap is open but doesn't while ArcMap isn't.   I am signing in to the portal in the code.

I get.
ERROR 000732: Server: Dataset My Hosted Services does not exist or is not supported

Here is a sample of my code - slightly censored.

print "Signing in to Portal"
arcpy.SignInToPortal_server("login", "password", "http://www.arcgis.com/")

# Process: Stage Service
arcpy.StageService_server("file.sddraft", "file.sd")

# Process: Upload Service Definition
arcpy.UploadServiceDefinition_server("file.sd", "My Hosted Services", "ServiceName", "", "FROM_SERVICE_DEFINITION", "", "STARTED", "USE_DEFINITION", "NO_SHARE_ONLINE", "PRIVATE", "NO_SHARE_ORGANIZATION", "")