HOW TO

Connect to a standalone ArcGIS Server using ArcGIS API for Python

Last Published: June 29, 2021

Summary

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.

Procedure

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.

  1. Import the necessary modules.
from arcgis.gis.server import Server
  1. Specify the domain.
server_base_url = "https://<machine>.<domain>.com"
  1. Create the connection by declaring a new parameter containing the token generation and credentials, and call the parameter.
#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

Software:
  • ArcGIS Server
  • ArcGIS API for Python 1 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic