Hi brains trust. I'm writing a python script that uses a feature service (table) as an input for an Export Table tool. I have the code working perfectly on my PC but not on the server where I intend to schedule it. They are running the same versions of Pro and python. The code is below, along with the error I'm getting. Is there a better way to do this (like I mentioned, this works fine on my PC).
# Variables - update these lines
SPDRoutes = "https://services3.arcgis.com/1GMgEwgl0qHnrBQf/arcgis/rest/services/Distances_Table/FeatureServer/0" # Feature service containing routes to be updated
import arcpy, time, os
# Overwrite Output
arcpy.env.overwriteOutput = True
import keyring
pw = keyring.get_password("ArcGISOnline", "MyUserName")
arcpy.SignInToPortal("https://fpcwa.maps.arcgis.com", "MyUserName", pw)
print("Connected to the GIS")
# Create temporary FGDB
sdproutesgdb = arcpy.CreateFileGDB_management(arcpy.env.scratchFolder, "sdproutes")
print ("Temp FGDB created")
arcpy.env.workspace = arcpy.env.scratchFolder + "\\sdproutes.gdb"
print ("Workspace set to temp FGDB")
# Compare existing SDP Routes to Updated SDP Harvest Plan
ExistingSDPRoutes = arcpy.conversion.ExportTable(
in_table = SPDRoutes,
out_table = arcpy.env.workspace + "\\ExistingSDPRoutes",
where_clause = "",
use_field_alias_as_name = "NOT_USE_ALIAS",
field_mapping = 'Name "Name" true true false 1024 Text 0 0,First,#,Plantation SDP Route Distances,Name,0,1024;Total_Length "Total_Length" true true false 0 Double 0 0,First,#,Plantation SDP Route Distances,Total_Length,-1,-1;GlobalID "GlobalID" false false true 38 GlobalID 0 0,First,#,Plantation SDP Route Distances,GlobalID,-1,-1;CreationDate "CreationDate" false true true 8 Date 0 0,First,#,Plantation SDP Route Distances,CreationDate,-1,-1;Creator "Creator" false true true 128 Text 0 0,First,#,Plantation SDP Route Distances,Creator,0,128;EditDate "EditDate" false true true 8 Date 0 0,First,#,Plantation SDP Route Distances,EditDate,-1,-1;Editor "Editor" false true true 128 Text 0 0,First,#,Plantation SDP Route Distances,Editor,0,128'
)
print ("Existing SDP Route distances exported")
Exception: Failed to execute. Parameters are not valid.
ERROR 000732: Input Table: Dataset https://services3.arcgis.com/1GMgEwgl0qHnrBQf/arcgis/rest/services/Distances_Table/FeatureServer/0 does not exist or is not supported
Failed to execute (ExportTable).
Lindsay Raabe
GIS Officer
Forest Products Commission WA