HI, I am trying to run a very simple python tool as Geo-processing Service. As usual I created the tool as follows:
import arcpy
inputLong = float(arcpy.GetParameterAsText(0))
inputLat = float(arcpy.GetParameterAsText(1))
xy = [(inputLat, inputLong)]
fc = r"Database Connections\Connection to XXX-XXXXX.sde\A.DBO.CropPoint"
cursor = arcpy.da.InsertCursor(fc, ["SHAPE@XY"])
for row in xy:
    cursor.insertRow([row])
del cursorand shared as Geo-processing Service on my ArcGIS server. On JavaScript I wrote the code as follows:
            var gpUrl = "http://XXX-XXXXX:6080/arcgis/rest/services/Script2/GPServer";
            var gp = new Geoprocessor(gpUrl);
                            var params1 = {
                                Longitude: -101.55,
                                Latitude: 35.6
                            };
                            gp.submitJob(params1);
It does not work (i.e. does not add point to my point map), however I can directly run it in the "ArcGIS REST Services Directory" on my browser. Also I tried "gp.execute(params1)" to run the tool.
Solved! Go to Solution.
Found the problem. The rest URL is :
http://XXX-XXXXX:6080/arcgis/rest/services/Script2/GPServerBu in the code you should use the complete url (that you can find " ArcGIS REST Services Directory" in the browser) as follows:
http://XXX-XXXXX:6080/arcgis/rest/services/Script2/GPServer/Script%201Mohammadreza,
When you published the geoprocessing service did you publish it as a synchronous or asynchronous service? This will help determine if you run execute or sumbitJob.
Second, when publishing the service what input types were selected for the parameters?
Best, - Tyler
Hello
I tried with both execute and submit job correctly.
The parameters are Double
Thanks
Found the problem. The rest URL is :
http://XXX-XXXXX:6080/arcgis/rest/services/Script2/GPServerBu in the code you should use the complete url (that you can find " ArcGIS REST Services Directory" in the browser) as follows:
http://XXX-XXXXX:6080/arcgis/rest/services/Script2/GPServer/Script%201