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).