GP service input parameter converted from string to integer when called from browser

3369
4
11-07-2012 02:05 PM
BryanBaker
Occasional Contributor
I have a 10.1 GP service task based on a Python script. At the top of the script I grab the input parameters, e.g.,

myId = arcpy.GetParameterAsText(0)
myId2 = arcpy.GetParameterAsText(1)

The parameters are all defined as String type in the Properties of the script within the ArcGIS toolbox. The second parameter has a format along the lines of 01207.000. We need this full string including leading zeroes and trailing digits.

When I use ArcMap/Catalog to run this GP service task, the parameters get read correctly and the script runs fine. However, when I run this task from the Services Directory, the second parameter has its format converted to 1207, i.e., leading and trailing zeroes are dropped, as if it's been parsed to an integer. This happens even when running the task from a browser on the server using port 6080.

I have used a packet sniffer (Wireshark) to confirm that the full format is being sent to the server. And in the script I've used arcpy.AddMessage to display the value as read by the script. In the Services Directory case that shows it is receiving the parameter in integer format.

Is there some reason the value would be getting converted between the browser and the script?
4 Replies
KevinHibma
Esri Regular Contributor
I'll have to test this.
I remember this was a bug during 10.1 beta cycle - I just looked it up and its set to fixed.

I'll see if its somehow come back or popping up in a different way.
0 Kudos
BryanBaker
Occasional Contributor
Any news on this one? It's gotten to be a bigger issue with us.

thanks,
Bryan
(Note: I am no longer with ESRI. I have asked the forum moderator to remove my ESRI logo.)
0 Kudos
PhilLarkin
New Contributor III

This is a pretty big problem for me as well.

0 Kudos
AndrewKeith3
Occasional Contributor

Try this:

str(arcpy.GetParameterAsText(1))

0 Kudos