0

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.

0
2

You should try to manage your AGOL data using the ArcGIS API for Python. https://developers.arcgis.com/python/. You can combine this with your ArcPy, and it should maintain your connection when you enter your credentials. I have not encountered this error when using the API.

2
  • That looks like it would be very useful. We are currently running python 2.7 and have a very stubborn and strict IT environment. We unfortunately wont be able to install python 3, which seems to be required for the ArcGIS API. We also are basically stuck with running python files through IDLE (no Anaconda or Jupyter) and have only been able to install libraries by downloading .whl files. (PiPy connections are blocked for pip)
    – jboges
    May 21 '20 at 14:33
  • Combining the two is what we use to accomplish what's described in the question, and it does work fine in IDLE.
    – JoshC
    May 29 '20 at 2:20
2

To answer your questioned, as-asked, is there anything I can do in ArcMap to maintain the connection to ArcGIS.COM: No. There is no Python command to do this. This "leaving ArcMap open" to keep your connection, is at best, a half-baked hack that didn't always work.

The Sign In To Portal tool was deprecated at 10.2. See the big legacy note in the help topic. The tool does work in ArcGIS Pro. So in theory if you could update to Pro, you could probably do your workflow as you have it.

If you want to do your workflow of having a Python script update features in ArcGIS Online and you're stuck at Python 2 / ArcMap -- you'll need to look into authenticating yourself and passing tokens. There are a few questions here on GIS.SE that talk about it. Or you can explore this github repro (with links to more detail blogs): https://github.com/arcpy/update-hosted-feature-service

1
  • the Github repo was the solution. Thank you
    – jboges
    May 21 '20 at 15:42

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.