I am working with ArcMap 10.5 on a corporate network though a VDI. We have been trying to implement a batch script which will pull data from an API to update features in a gdb, which then updates the souces in an MXD. This all works just fine. However, the script then tries to automate publishing the MXD to overwrite a featureservice in an ArcGIS Online developer account, and even though we are passing our login credentials to the
arcpy.SignInToPortal_server function, we get this error message:
Traceback (most recent call last): File "(path to python script)/UpdateDashboardService.py", line 95, in <module> "PUBLIC", "SHARE_ORGANIZATION", "") File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\server.py", line 1509, in UploadServiceDefinition raise e arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Server: Dataset My Hosted Services does not exist or is not supported WARNING 001404: You are not signed in to ArcGIS Online. Failed to execute (UploadServiceDefinition).
After doing some searching online we found a workaround where if you have an ArcMap document open through the GUI and signed in to the account and then run the batch, the stand alone script will work and the features will be updated to the developer account. This does work, however we really are trying to make this completely standalone and not require more than just running the batch the script is part of so that this process is as seamless as possible. Requiring the user to manually open ArcMap and sign in to the service is not ideal.
I'm wondering if there is an ArcPy function or tool that will force the ArcGIS Connection Utility to display we are logged in without having to have the MXD open.