HOW TO
ArcGIS API for Python is designed to work with ArcGIS Enterprise, specifically a federated ArcGIS Server instance with Portal for ArcGIS. However, there are times when a stand-alone ArcGIS Server is implemented on a machine and a connection through ArcGIS API for Python fails.
To connect to a stand-alone ArcGIS Server instance through ArcGIS API for Python, the usual GIS() function cannot be used. As a workaround, the connection must be made through a parameter function containing the required token and calling the parameter. The following procedure describes how to do so.
from arcgis.gis.server import Server
server_base_url = "https://<machine>.<domain>.com"
#For HTTPS server = Server(url="{}:6443/arcgis/admin".format(server_base_url), tokenurl="{}:6443/arcgis/rest/generateToken".format(server_base_url), username="<insert_username_here>", password="<insert_password_here>") #For HTTP server = Server(url="{}:6080/arcgis/admin".format(server_base_url), tokenurl="{}:6080/arcgis/rest/generateToken".format(server_base_url), username="<insert_username_here>", password="<insert_password_here>") server
The following shows a sample of the full script.
from arcgis.gis.server import Server server_base_url = "https://test.esri.com" server = Server(url="{}:6443/arcgis/admin".format(server_base_url), tokenurl="{}:6443/arcgis/rest/generateToken".format(server_base_url), username="username", password="password") server
Article ID: 000021053
Get help from ArcGIS experts
Download the Esri Support App