Publish custom geoprocessing tool via ArcGIS API for Python

816
2
08-23-2021 12:52 AM
SuryaKant1
New Contributor II

Hello,

 

I am trying to automate publishing of geoprocessing tool via ArcGIS API for Python. For this I have created a very simple tool which takes a string and returns it with Hello prefix. Created a tool in ArcGIS Pro and also have the SD file of the same. 

How can I publish it to Portal with ArcGIS API for Python? 

My ArcGIS environment is Portal for ArcGIS, federated ArcGIS Server (Hosting role), Web adaptor. All are version 10.8.1

 

While searching on the topic I came across with a solution using 

arcpy.server.UploadServiceDefinition

 document link 

This method is throwing error "arcgisscripting.ExecuteError: ERROR 160203: Failed to load a resource (string, icon, bitmap, etc)
Failed to execute (UploadServiceDefinition)."

 

Any help would be appreciated. My goal is to publish and check the GP tool is working and then remove it since it is a test only.

 

Thanks

0 Kudos
2 Replies
mody_buchbinder
Occasional Contributor III

Hi

First you are using arcpy library and not Python API (library name arcgis).

Publishing with Python is working, it looks like you have a problem with the parameters.

You can try to publish with the existing tool (not the script), it basically call the same tools, if it works compare the parameters to your script, if not then the problem is not in the script but in the data somewhere.

You can post a short version of your script, other people eyes can sometime see things that you do not see.

Have Fun

SuryaKant1
New Contributor II

Hi,

Thank you for the reply. For the most part I am using GIS object to from arcgis module for content publishing. Since, I am not able to publish any geoprocessing tool via publish method 

item.publish()  # here item is arcgis.gis.Item object

I was checking on any other option to publish (probably) via arcpy. But I want to avoid arcpy module. Could I publish the GP tool with ArcGIS API for Python? Could you please provide any example (sample)?

Thanks again

 

0 Kudos