Field Aliases missing in JSON response for geoprocessing service

1246
1
11-30-2011 12:33 PM
FredSpataro
Occasional Contributor III
Hello All:

I'm exposing some of our more complex analytical processes thru Geoprocessing services.  This has proved extremely efficient, reducing client side code and maintainability.  The integrated nature of the GP server with the WebAPIs also makes these very easy to access and execute.  However we've run into one issue and while minor in the larger pictures, causes majors headaches in the client code. 

Basically we've found that the "featureset" returned by the geoprocessing service is missing the field aliases when you use the 'JSON' format in the REST API. However they DO come thru in the SOAP API (ArcGIS Explorer test) and the REST API if you select format = HTML or KMZ.  If we use any of the WebAPIs the field aliases are missing. 

Here's a simple way to test:

1. Create a simple feature class with a few records and a few columns with alias names
2. Create a python script that opens and returns the feature class

#any feature class with aliases
output = "C:\\arcgisserver\\Temp.gdb\\AliasTest"
arcpy.SetParameter(0,output)

3. Load the script to a toolbox
4. Publish the toolbox as a service

5. Access the GP service in ArcGIS Explorer... field aliases are displayed
6. Access the GP service in the REST wisywig page with format = HTML... field aliases are display
7. Access the GP service in the REST wisywig page with format = JSON... Aliases attribute is missing  in the JSON featureset JSON structure. 
8. Access the GP service with any of the WebAPIs ---  same as the JSON result
9. Access the GP service with the REST wisywig page with format KMZ... GE opens and the aliases are displayed.

Again it's not a show stopping issue but without the aliases the field names are no longer user friendly and if we have to code the aliases in the client application is makes it harder to maintain and change the service on the fly. 

Is anyone else able to reproduce this?  Is there a specific setting needed to get the aliases to come thru or is it a bug?  Seems odd the aliases would be available for Google Earth/KMZ but not supported in the JSON for the WebAPIs
0 Kudos
1 Reply
nicogis
MVP Frequent Contributor
I have seen this problem.

Workaround:
you can get this information from rest in defaultValue -> field:

see this sample url:
http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Network/ESRI_DriveTime_US/GPServer/Create...

in js api you can use a esri.request
you return a object:
you get parameters
objects.parameters

loop on this array of parameters and using name for find your parameter and then you get objects.parameters.fields so you have  Field Aliases

see also this sample esri:
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/data_requestLayerInfo.html
0 Kudos