I've published a GP tool with a string choice list input but when I try and call it, I get error 000800.
Request URL: http://srv:6080/arcgis/rest/services/Test/LFPSetupBasicSDE/GPServer/LFP%20Setup%20Basic%20SDE/submit...
Response:
ERROR 000800: The value is not a member of 47.85 | 67.00 | 95.75 | 138.90 | 203.70 | 301.00 | 447.05 | 666.30 | 995.55 | 1500.85.
The Water_Depth value is clearly in the list, but I'm wondering if it's being received as a float. In both my javascript code for the site and the tool python script it is handled as a string and the tool parameter input is set to string.
Unsurprisingly, the help for this error is no help at all.
Does anyone know how POST requests are interpreted on the server? Are all the values taken to be strings, or does it attempt to parse numbers?
Cross-posting in Geoprocessing and ArcGIS API for JavaScript
When you check the service at Rest, is there a default value for that parameter? If so, is it in quotes or is it unquoted? There should be a default value, which would be the value you used when you ran it originally in ArcMap before publishing, so you could try to just submit the job at Rest with the default parameters to make sure it goes through.
The default value is unquoted:
Parameter: WATER_Depth
Data Type: GPString
Display Name WATER Depth
Description: description
Direction: esriGPParameterDirectionInput
Default Value: 203.70
Parameter Type: esriGPParameterTypeRequired
Category:
Choice List: [ 47.85, 67.00, 95.75, 138.90, 203.70, 301.00, 447.05, 666.30, 995.55, 1500.85 ]
When you submit empty parameters, it runs through ok.
I've actually just taken out the choice list altogether and republished it - we decided that as we're calling this service from our site, we can just set the allowed values into a dropdown on the web page.
UPDATE:
I've looked a bit further into this and something is definitely parsing the input, so even though the values are going into the GP service as strings, they have been rounded off.
I made a tool with the following script:
import arcpy string_var1 = arcpy.GetParameterAsText(0) string_var2 = arcpy.GetParameter(1) double_var1 = arcpy.GetParameterAsText(2) double_var2 = arcpy.GetParameter(3) arcpy.AddMessage('String var 1 is a %s, value %s.' % (type(string_var1), string_var1)) arcpy.AddMessage('String var 2 is a %s, value %s.' % (type(string_var2), string_var2)) arcpy.AddMessage('Double var 1 is a %s, value %s.' % (type(double_var1), double_var1)) arcpy.AddMessage('Double var 2 is a %s, value %s.' % (type(double_var2), double_var2))
Then published it so the REST directory looks like:
Parameters:
Parameter: string1
Data Type: GPString
Display Name string1
Description:
Direction: esriGPParameterDirectionInput
Default Value: 10.100
Parameter Type: esriGPParameterTypeRequired
Category:
Parameter: string2
Data Type: GPString
Display Name string2
Description:
Direction: esriGPParameterDirectionInput
Default Value: 10.100
Parameter Type: esriGPParameterTypeRequired
Category:
Parameter: double1
Data Type: GPDouble
Display Name double1
Description:
Direction: esriGPParameterDirectionInput
Default Value: 10.1
Parameter Type: esriGPParameterTypeRequired
Category:
Parameter: double2
Data Type: GPDouble
Display Name double2
Description:
Direction: esriGPParameterDirectionInput
Default Value: 10.1
Parameter Type: esriGPParameterTypeRequired
Category:
If you call it with no parameters (params = {}), it uses the defaults and the output is:
2015-07-16 11:41:45.093 core.js:186 String var 1 is a <type 'unicode'>, value 10.100.
2015-07-16 11:41:45.095 core.js:186 String var 2 is a <type 'unicode'>, value 10.100.
2015-07-16 11:41:45.097 core.js:195 Double var 1 is a <type 'unicode'>, value 10.1.
2015-07-16 11:41:45.099 core.js:195 Double var 2 is a <type 'float'>, value 10.1.
But if you pass in some values, they are truncated:
params = { | ||
"string1": "1.1200", | ||
"string2": "1.1200", | ||
"double1": 1.1200, | ||
"double2": 1.1200 | ||
}; |
2015-07-16 11:38:33.552 core.js:199 String var 1 is a <type 'unicode'>, value 1.12.
2015-07-16 11:38:33.553 core.js:199 String var 2 is a <type 'unicode'>, value 1.12.
2015-07-16 11:38:33.555 core.js:199 Double var 1 is a <type 'unicode'>, value 1.12.
2015-07-16 11:38:33.556 core.js:199 Double var 2 is a <type 'float'>, value 1.12.
I guess the answer is to alter the script to interpret the inputs as doubles, but it's annoying that something is being clever along the way and changing my values.
Hi Jon,
Your initial tests are clearly showing truncation to intergers or string. You could try parsing as a float parseFloat("1.1200") and see if that has any impact on the value.
Probably not the most graceful suggestion, but I would agree that one way of testing the issue would be to set the input parameters as String and convert that String to a float or decimal (How do I convert a string to a double in Python? - Stack Overflow ) within your initial tool.