Select to view content in your preferred language

Overwrite Web Layer with Arcpy (ArcGIS Pro)

4694
1
04-29-2016 02:43 AM
srikanthkurukundu
Deactivated User

Hi All,

I am working on task to update MultiPatch data published as a Web Layer to ArcGIS portal, To achieve this I have written python script to overwrite Web Layer by referring to Upload Service Definition—Help | ArcGIS for Desktop .

But ended with error!!

ExecuteError("ERROR 999999: Error executing function.\nService name 'Test_Publish' already exists for '0123456789ABCDEF'\nFailed to execute (UploadServiceDefinition).\n",).

Anyone achieved this? appreciate for any ideas! Thanks in Advance. In case if i am doing something wrong please flash. Python function as below.

def publishWebLayer(market):

    try:

        layerName = market+"_"+"Buildings_WithInfo";

        aprx = arcpy.mp.ArcGISProject('C:\\Users\\jll.innovation\\Documents\\ArcGIS\\Projects\\Lease_Services\\Lease_Services.aprx');

        m = aprx.listMaps('Map')[0];

        lyrs=[]; 

        lyrs.append(m.listLayers(layerName)[0]);

        serviceName = 'Test_Publish';

        sddraftFile = 'C:\\Users\\jll.innovation\\Documents\\ArcGIS\\Projects\\Lease_Services\\Lease_Service.sddraft';

        sdFile = 'C:\\Users\\jll.innovation\\Documents\\ArcGIS\\Projects\\Lease_Services\\Lease_Service.sd';

        ## Delete file if exist

        if arcpy.Exists(sddraftFile):

                    arcpy.Delete_management(sddraftFile);

        if arcpy.Exists(sdFile):

                    arcpy.Delete_management(sdFile);

        arcpy.mp.CreateWebLayerSDDraft(lyrs, sddraftFile,serviceName,'MY_HOSTED_SERVICES',                'FEATURE_ACCESS','APAC',True,True);

        arcpy.StageService_server(sddraftFile,sdFile); 

       arcpy.UploadServiceDefinition_server(sdFile, 'My Hosted                          Services',serviceName,'','EXISTING','APAC','','OVERRIDE_DEFINITION',

                        'NO_SHARE_ONLINE','PRIVATE','NO_SHARE_ORGANIZATION','');        

    except Exception as err:

        exc_type, exc_obj, exc_tb = sys.exc_info()

        fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]

        print((exc_type,exc_obj, fname, exc_tb.tb_lineno));

    return;

Tags (2)
0 Kudos
1 Reply
JDBurroughs1
Occasional Contributor

Did you ever find a solution to this? I'm looking for a solution to get multipatch web layers to update.