ArcGIS GP service failing - Bad syntax in request

5992
4
Jump to solution
04-02-2018 02:33 PM
KeithMiller4
New Contributor III

My geoprocessing service is failing with the errors:

ExecuteError: ERROR 999999: Error executing function.
An event was unable to invoke any of the subscribers [Execute error]
Bad syntax in request. (status code 400).

And here's the script that is being called. p0 is the derived output raster and p1 is the input raster.

def function(p0, p1):

    import arcpy
    import os
    from arcpy.sa import *

    scratchFolder = arcpy.env.scratchFolder
    arcpy.AddMessage('arcpy.env.scratchFolder: ' + arcpy.env.scratchFolder)
    arcpy.AddMessage(str(p1))

    output = os.path.join(scratchFolder, "output.tif")
    arcpy.AddMessage(output)
    Fill(p1).save(output)

    arcpy.SetParameter(0, output)

    return

I'm running ArcGIS Server 10.6 on Windows Server 2016 and the geoprocessing service was published from ArcGIS Desktop 10.6 on my PC running Windows 7. The server does not have ArcGIS desktop installed on it and never did.

Initially I thought it was a Spatial Analyst licencing problem but if I swap the offending Fill(p1).save(output) line with Negate(p1).save(output), with Negate being another SA tool, then it works fine and so the licence is ok. FlowDirection also fails in the same way as Fill.

The tool runs fine on ArcGIS Desktop on my PC. This is a simplified version of my tool to illustrate the error more clearly.

Here's the complete output messages from the script in case that helps:

Server Messages
Submitted.
Executing...
Executing (SA test): SATest d:\arcgis\arcgisserver\directories\arcgisjobs\satest_gpserver\j08d619f38d944d2a8df0cfae9a06d975\scratch\Input_raster.tif
Start Time: Tue Apr 3 09:24:09 2018
Executing (SATest): SATest d:\arcgis\arcgisserver\directories\arcgisjobs\satest_gpserver\j08d619f38d944d2a8df0cfae9a06d975\scratch\Input_raster.tif
Start Time: Tue Apr 3 09:24:09 2018
Running script SATest...
arcpy.env.scratchFolder: d:\arcgis\arcgisserver\directories\arcgisjobs\satest_gpserver\j08d619f38d944d2a8df0cfae9a06d975\scratch
d:\arcgis\arcgisserver\directories\arcgisjobs\satest_gpserver\j08d619f38d944d2a8df0cfae9a06d975\scratch\Input_raster.tif
d:\arcgis\arcgisserver\directories\arcgisjobs\satest_gpserver\j08d619f38d944d2a8df0cfae9a06d975\scratch\output.tif

Traceback (most recent call last):
File "<string>", line 97, in execute
File "C:\python27\ArcGISx6410.6\lib\site-packages\LUCItools\wstools\wst_sa_test.py", line 13, in function
Fill(p1).save(output)
File "c:\program files\arcgis\server\arcpy\arcpy\sa\Functions.py", line 2289, in Fill
z_limit)
File "c:\program files\arcgis\server\arcpy\arcpy\sa\Utils.py", line 53, in swapper
result = wrapper(*args, **kwargs)
File "c:\program files\arcgis\server\arcpy\arcpy\sa\Functions.py", line 2285, in Wrapper
z_limit)
File "c:\program files\arcgis\server\arcpy\arcpy\geoprocessing\_base.py", line 510, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
ExecuteError: ERROR 999999: Error executing function.
An event was unable to invoke any of the subscribers [Execute error]
Bad syntax in request. (status code 400).
Failed to execute (Fill).


Failed to execute (SATest).
Failed at Tue Apr 3 09:24:09 2018 (Elapsed Time: 0.37 seconds)
Failed to execute (SA test).
Failed at Tue Apr 3 09:24:09 2018 (Elapsed Time: 0.40 seconds)
Failed.

Thanks in advance!

0 Kudos
1 Solution

Accepted Solutions
KeithMiller4
New Contributor III

Solved my problem.

The issue was that 3 services in the System folder (RasterAnalysisTools, RasterProcessing and RasterRendering) were stopped. As far as I can work out they come with the ArcGIS Image Server package and they're stopped by default unless you link the Image Server with the ArcGIS portal (my ArcGIS Server is part of the base ArcGIS Enterprise installation I did using the ArcGIS Enterprise Builder).

Sp, you can just start the services manually, but if you link the Image Server to Portal then these services start automatically which is handy if/when you restart the server. Here's the docs that tell you how to do this.

I worked out that the problem was something to do with Image Server by looking in the ArcGIS Server logs. I found the following SOAP error:

Error handling request to service 'System/RasterProcessing.ImageServer'. java.lang.Exception: Could not find service. Service may be stopped or it may not be configured.

It seems that even though I couldn't find any documentation saying that Spatial Analyst depends on the Raster Analysis server (and hence Image Server) to be present / running, it seems that it does.

An aside: weirdly, the Fill tool ran ok before starting the 3 raster analysis services up when I ran it in an IDLE session on the server and not as part of a geoprocessing task. I only had this problem when running it as a GP task.

View solution in original post

4 Replies
KeithMiller4
New Contributor III

Forgot to say - the ArcGIS Server is part of a base ArcGIS Enterprise install I did using the ArcGIS Enterprise Builder.

0 Kudos
BalajiVeera
Occasional Contributor

Try with change the syntax for line Fill (Bad syntax in request)

Fill(p1).save(output)

--replace with

outF = Fill(p1)

outF.save(output)

0 Kudos
KeithMiller4
New Contributor III

I tried that but no joy. The problem is definitely with the Fill function.

0 Kudos
KeithMiller4
New Contributor III

Solved my problem.

The issue was that 3 services in the System folder (RasterAnalysisTools, RasterProcessing and RasterRendering) were stopped. As far as I can work out they come with the ArcGIS Image Server package and they're stopped by default unless you link the Image Server with the ArcGIS portal (my ArcGIS Server is part of the base ArcGIS Enterprise installation I did using the ArcGIS Enterprise Builder).

Sp, you can just start the services manually, but if you link the Image Server to Portal then these services start automatically which is handy if/when you restart the server. Here's the docs that tell you how to do this.

I worked out that the problem was something to do with Image Server by looking in the ArcGIS Server logs. I found the following SOAP error:

Error handling request to service 'System/RasterProcessing.ImageServer'. java.lang.Exception: Could not find service. Service may be stopped or it may not be configured.

It seems that even though I couldn't find any documentation saying that Spatial Analyst depends on the Raster Analysis server (and hence Image Server) to be present / running, it seems that it does.

An aside: weirdly, the Fill tool ran ok before starting the 3 raster analysis services up when I ran it in an IDLE session on the server and not as part of a geoprocessing task. I only had this problem when running it as a GP task.