Hello,
I am writing to request technical assistance. I created a python script that needs to execute the following, in the indicated order:
1) generate some rasters,
2) add the rasters to a map
3) publish the map as a MAP_IMAGE to an ArcGIS Server federated with a Portal.
I published the python script to ArcGis Server as a Web Tool, so I can later use it from a web app as a REST Service.
The problem I am experiencing is: Once the webtool is created and I try to execute it as a rest service from the browser I get errors. Please see below for Code Version 1 and its errors and Code Version 2 and its errors;
Version 1
Code:
# ## Version 1 - Using map.getWebLayerSharingDraft
sharing_draft = _work_map.getWebLayerSharingDraft('FEDERATED_SERVER', 'MAP_IMAGE', service)
sharing_draft.federatedServerUrl = str(svr_fed)
sharing_draft.summary = _work_map.name
sharing_draft.tags = _work_map.name
sharing_draft.description = 'Create Rasters'
sharing_draft.credits = 'Create Rasters'
sharing_draft.useLimitations = 'My Use Limitations'
sharing_draft.copyDataToServer = True
sharing_draft.offline = False
sharing_draft.overwriteExistingService = True
# ## End Version 1
Error:
'Map' object has no attribute 'getWebLayerSharingDraft'
Version 2
Code:
# ## Version 2 - Using arcpy.sharing.CreateSharingDraft
sharing_draft = arcpy.sharing.CreateSharingDraft("STANDALONE_SERVER", "MAP_SERVICE", service, _work_map)
sharing_draft.targetServer = svr_fed
sharing_draft.summary = _work_map.name
sharing_draft.tags = _work_map.name
sharing_draft.description = 'Create Rasters'
sharing_draft.credits = 'Create Rasters'
sharing_draft.useLimitations = 'My Use Limitations'
sharing_draft.copyDataToServer = True
sharing_draft.offline = True
sharing_draft.overwriteExistingService = True
# ## End Version 2
Error:
module 'arcpy' has no attribute 'sharing'
Both versions run perfectly in ArcGis Pro
ArcGIS version: Pro 2.3.0, Python version: 3.6.6
Python version on ArcGis Server: 2.7
Some Links consulted;
https://pro.arcgis.com/en/pro-app/arcpy/sharing/mapimagesharingdraft-class.htm
https://pro.arcgis.com/en/pro-app/arcpy/sharing/mapservicedraft-class.htm
https://community.esri.com/thread/223789-getweblayersharingdraft-not-found
thank you