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