1

Here is my code

def upload(name, client, working_dir):
 arcpy.env.overwriteOutput = True
 arcpy.SignInToPortal('https://www.arcgis.com', username, password)
 outdir = working_dir + "\\PROJECTS\\" + name + "\\sd\\"
 aprx = arcpy.mp.ArcGISProject(working_dir + "\\PROJECTS\\data_holder\\data_holder.aprx")
 m = aprx.listMaps()[0]
 print("Uploading data for " + name)
 lyrs = m.listLayers()
 arcpy.mp.CreateWebLayerSDDraft(lyrs, outdir + name + ".sddraft", name, "MY_HOSTED_SERVICES", "FEATURE_ACCESS", name, True, True, False, False, False, name, name, name, None, None )
 arcpy.StageService_server(outdir + name + ".sddraft", outdir + name + ".sd", 102)
 arcpy.UploadServiceDefinition_server(outdir + name + ".sd", 'My Hosted Services')

This is the error I am getting. I have tried multiple different ways to put in parameters.

Uploading data for test_project

Traceback (most recent call last):

File "main.py", line 304, in module

upload(name, client, working_dir)

File "main.py", line 242, in upload

arcpy.UploadServiceDefinition_server(outdir + name + ".sd", 'My Hosted Services')

File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\server.py", line 954, in UploadServiceDefinition raise e

File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\server.py", line 951, in UploadServiceDefinition retval = convertArcObjectToPythonObject(gp.UploadServiceDefinition_server(*gp_fixargs((in_sd_file, in_server, in_service_name, in_cluster, in_folder_type, in_folder, in_startupType, in_override, in_my_contents, in_public, in_organization, in_groups), True)))

File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing_base.py", line 506, in return lambda *args: val(*gp_fixargs(args, True))

arcgisscripting.ExecuteError: ERROR 999999: Error executing function.

ERROR: code:400, Invalid URL, Invalid URL, Bad syntax in request.

Failed to execute (UploadServiceDefinition).

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Jun 26, 2018 at 20:36
3
  • 1
    thats not your portal URL Commented Jun 26, 2018 at 20:54
  • Hmm. What would it be then? It seems to be connecting to my account and upload a service definition that is unusable from the code above. Commented Jun 26, 2018 at 21:19
  • 1
    ERROR: code:400, Invalid URL, Invalid URL, Bad syntax in request. Commented Jun 27, 2018 at 18:14

1 Answer 1

1

The issue was that I was trying to upload an xy event layer. I changed my code to upload from a gdb.

answered Jun 27, 2018 at 18:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.