Be The First To Get Support Updates
Want to know about the latest technical content and software updates?

How To: Publish a custom print service with embedded credentials from ArcGIS Pro to a standalone ArcGIS Server site


The instructions below describe how modify the Export Web Map task with embedded credentials, and publish it as a custom print geoprocessing service from ArcGIS Pro to a standalone ArcGIS Server site.


  1. Modify the Export Web Map task.
    1. Locate the Export Web Map Python tool in ArcGIS Pro. Navigate to Geoprocessing > Toolboxes > Server Tools > Printing.
    2. Right-click Export Web Map and select Edit to open the script file.
    3. Copy and paste the script into a new text editor, for example, Notepad. Edit the script to include the ImportCredentials and ClearCredentials functions to match the following script. The following example is a script that takes the state of a web map in a web application (for example, included services, layer visibility settings, and client-side graphics) and returns a printable page layout or basic map of the specified area of interest in the vector (such as pdf, svg, etc.) or image (such as png, jpeg, etc.).
# Import required modules
import sys
import os
import arcpy
import uuid

# constants
MAP_ONLY = 'map_only'

# Specify credentials for secured services in the WebMap JSON
secure_server_connections = [r'C:\Users\<username>\server on <connection file name>.ags']

# Import credentials
importedConnections = arcpy.ImportCredentials(secure_server_connections)

# default location and current product name
_defTmpltFolder = os.path.join (arcpy.GetInstallInfo()['InstallDir'], r"Resources\ArcToolBox\Templates\ExportWebMapTemplates")
_prodName = arcpy.GetInstallInfo()['ProductName']
_isMapOnly = False

# export only map without any layout elements
def exportMap(result, outfile, outFormat):
	# Set output parameter
	arcpy.SetParameterAsText(1, outfilename)
	# Clear credentials
if __name__ == "__main__":
  1. Save the file as a .py file and name the file as ExportWebMapSecured.py.
  2. In ArcGIS Pro, add the script to a toolbox. Refer to ArcGIS Pro: Add a script tool for more information. In the Parameters tab, match the parameters from the Export Web Map Python tool as shown in the following images.
Setting parameters in the Export Web Map script tool properties dialog
Setting parameters in the Export Web Map script tool properties dialog
  1. Run the script tool in ArcGIS Pro.
Ensure to fill-out the Layout Template field.
Setting parameters in the ExportWebMapSecured geoprocessing properties dialog

The following is a WebMap as JSON example:

{"mapOptions":{"showAttribution":true,"extent":{"xmin":-37570328.14272009,"ymin":-15552387.679177042,"xmax":37570328.14272009,"ymax":19552387.679177042,"spatialReference":{"wkt":"PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator_Auxiliary_Sphere\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",0],PARAMETER[\"Standard_Parallel_1\",0.0],PARAMETER[\"Auxiliary_Sphere_Type\",0.0],UNIT[\"Meter\",1.0]]"}},"spatialReference":{"wkt":"PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator_Auxiliary_Sphere\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",0],PARAMETER[\"Standard_Parallel_1\",0.0],PARAMETER[\"Auxiliary_Sphere_Type\",0.0],UNIT[\"Meter\",1.0]]"},"scale":147914381.897889},"operationalLayers":[{"id":"defaultBasemap","title":"World Topographic Map","opacity":1,"minScale":0,"maxScale":0,"url":"https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"}],"exportOptions":{"outputSize":[670,500],"dpi":96},"layoutOptions":{"titleText":"","authorText":"","copyrightText":"","customTextElements":[{"Date":"12/9/2019, 9:17:04 AM"}],"scaleBarOptions":{"metricUnit":"esriKilometers","metricLabel":"km","nonMetricUnit":"esriMiles","nonMetricLabel":"mi"},"legendOptions":{"operationalLayers":[]}}}
  1. Connect to the ArcGIS Server site and change the connection type to Administrator Connection to publish the geoprocessing service.
Setting the connection type in the ArcGIS Server Connection Properties dialog
  1. Publish the successful result as a geoprocessing service.
Publishing the geoprocessing service
  1. Test the published geoprocessing service by replacing the URL with the IWA-secured URL from the in-house server site in the Web Map as JSON example.

Related Information

Last Published: 1/19/2023

Article ID: 000026010

Software: ArcGIS Pro 2.9.6, 2.9.5, 2.9.4, 2.9.3, 2.9.2, 2.9.1, 2.9, 2.8.8, 2.8.7, 2.8.6, 2.8.5, 2.8.4, 2.8.3, 2.8.2, 2.8.1, 2.8, 2.7.7, 2.7.6, 2.7.5, 2.7.4, 2.7.3, 2.7.2, 2.7.1, 2.7, 2.4.3, 2.4.2, 2.4.1, 2.4, 2.3.3, 2.3.2, 2.3.1, 2.3, 2.2.4, 2.2.3, 2.2.2, 2.2.1, 2.2, 2.1.3, 2.1.2, 2.1.1, 2.1, 2.0.1, 2.0 ArcGIS Server 10.9.1, 10.9, 10.8.1, 10.8, 10.7.1, 10.7, 10.6.1, 10.6