ArcGIS Server - AttributeError: module 'arcpy' has no attribute 'ImportCredentials'

Jump to solution
04-09-2019 12:49 PM
New Contributor II

I have a geoprocessing service on my standalone ArcGIS Server v10.6.1 to perform advanced printing for web maps using from ArcGIS Pro v2.3.1. Our application accesses secure services so I need to include the arcpy.ImportCredentials function. When I run the script I get the following error:

Error executing tool. ConvertPdf : Traceback (most recent call last): File "D:\arcgisserver\directories\arcgissystem\arcgisinput\GP\ConvertPdf.GPServer\extracted\p20\arcgis_project\", line 36, in importedConnections = arcpy.ImportCredentials(secure_server_connections) AttributeError: module 'arcpy' has no attribute 'ImportCredentials' Failed to execute (ConvertPdf). Failed to execute (ConvertPdf).

If I remove the ImportCredentials function, the script works and generates an image (if my web map json doesn't include a secure service).

We are not using Portal and therefore this is not a federated server. So I am not able publish this service as a web tool. I had to write a script to create a service draft using arcpy.CreateGPSDDraft and used UploadServiceDefinition to publish to our server. The service appears to be using the propy python environment because it successfully uses the module, but I don't know why it fails on ImportCredentials.

Here is the code published to the server:

import arcpy
import os
import uuid

# The template location in the server data store
scriptPath = sys.path[0]
templatePath = os.path.join(scriptPath, 'Templates')

# Input WebMap JSON
Web_Map_as_JSON = arcpy.GetParameterAsText(0)

# Input layout template
Layout_Template = arcpy.GetParameterAsText(1)

# Get the requested layout template pagx file
templatePagx = os.path.join(templatePath, Layout_Template + '.pagx')

# Specify credentials for secured services in the WebMap JSON
secure_server_connections = [
    os.path.join(scriptPath, 'creds.ags'),

# Import credentials
importedConnections = arcpy.ImportCredentials(secure_server_connections)
# Convert the WebMap to an ArcGISProject
result =, templatePagx, 'LetterLandscape')
aprx = result.ArcGISProject
layout = aprx.listLayouts()[0]

# Set scale
scale = arcpy.GetParameterAsText(3)
layout = aprx.listLayouts('LetterLandscape')[0]
mapframe = layout.listElements('MapFrame_Element')[0] = scale

# Set rotation
rotate = arcpy.GetParameterAsText(4) = rotate
# Use the uuid module to generate a GUID as part of the output name
# This will ensure a unique output name
output = 'WebMap_{}.png'.format(str(uuid.uuid1()))
Output_File = os.path.join(arcpy.env.scratchFolder, output)

# Export the WebMap
dpi = arcpy.GetParameterAsText(5)
layout.exportToPNG(Output_File, int(dpi))

# Set the output parameter to be the output file of the server job
arcpy.SetParameterAsText(2, Output_File) 

# Clear credentials

# Clean up
del layout, aprx, result

Any ideas on how I can get this to work on our server?


0 Kudos
1 Solution

Accepted Solutions
Esri Regular Contributor

ImportCredentials() was introduced in Pro 2.3 release. On the server side, you need 10.7 or higher.

View solution in original post

6 Replies
by MVP Regular Contributor
MVP Regular Contributor

Hi Christopher

Have you found a solution for this? I am having the same issue here...


0 Kudos
Esri Regular Contributor

ImportCredentials() was introduced in Pro 2.3 release. On the server side, you need 10.7 or higher.

by MVP Regular Contributor
MVP Regular Contributor

Thanks for giving the clarification. we are on 10.6.1.

0 Kudos
New Contributor II

Thanks Tanu Hoque‌. We are also on 10.6.1.

0 Kudos
New Contributor III

@TANH is the only solution to this problem to upgrade an ArcGIS Server instance to 10.7 or higher? I have a geoprocessing service that is trying to access premium layers in an aprx and, while this works locally before publishing, it will not work when running on our ArcGIS Server install at 10.6.1. Without the ImportCredentials module available, I don't see any other options short of doing a full upgrade. Is that right? Could I just port the geoprocessing service over to arcpy.mapping and python 2.7 to use the equivalent there? Thanks in advance

0 Kudos
Esri Regular Contributor


yes, that is correct. you need to update your server to 10.7 or higher. And then use ArcGIS Pro 2.3 or higher to publish your service from.

0 Kudos