AnsweredAssumed Answered

JSONToFeatures_converson - ArcGIS Server GPService fails

Question asked by pfoppe on Aug 5, 2013
Latest reply on Apr 11, 2014 by donbrown44
I love the new JSONToFeature_conversion tool that was just released at 10.2

Works great when running it from ArcGIS Desktop, but not from ArcGIS Server...  Here is a simple script and output.  I would rather pass in the RAW JSON data rather than store it to a file so the script accepts basic text (string param type) and creates the JSON file, stores the text and runs the tool. 


import os import arcpy from datetime import datetime   ###################################### ######  Getting params   ###### ###################################### input_json=arcpy.GetParameterAsText(0)     ###################################### ######  Store Data   ###### ###################################### dt="DATA_EXTRACT_"+datetime.today().strftime("%y%m%d_%H%M%S") json_file=os.path.join(arcpy.env.scratchFolder,"%s.json"%dt) fc=os.path.join(arcpy.env.scratchGDB,dt)    ###CONVERT JSON TO FC### arcpy.AddMessage("Converting JSON to FC...") f=open(json_file,'w') f.write(input_json) f.close() res=arcpy.JSONToFeatures_conversion(json_file,fc)    ###Storing result...###  arcpy.SetParameter(1,arcpy.FeatureSet(fc))


Here is a real simple JSON input:
{"features": [{"geometry": {"y": 35.748388281000075, "x": -114.85761096699997}, "attributes": {"SITENAME": "MYSITE", "OBJECTID": 1}}], "fieldAliases": {"SITENAME": "SITENAME", "OBJECTID": "OBJECTID"}, "fields": [{"alias": "OBJECTID", "type": "esriFieldTypeOID", "name": "OBJECTID"}, {"alias": "SITENAME", "length": 70, "type": "esriFieldTypeString", "name": "SITENAME"}], "displayFieldName": "SITENAME", "spatialReference": {"wkid": 4269, "latestWkid": 4269}, "geometryType": "esriGeometryPoint"}


If you run this from desktop then here is the result:
Executing: JsonToFc "{"features": [{"geometry": {"y": 35.748388281000075, "x": -114.85761096699997}, "attributes": {"SITENAME": "MYSITE", "OBJECTID": 1}}], "fieldAliases": {"SITENAME": "SITENAME", "OBJECTID": "OBJECTID"}, "fields": [{"alias": "OBJECTID", "type": "esriFieldTypeOID", "name": "OBJECTID"}, {"alias": "SITENAME", "length": 70, "type": "esriFieldTypeString", "name": "SITENAME"}], "displayFieldName": "SITENAME", "spatialReference": {"wkid": 4269, "latestWkid": 4269}, "geometryType": "esriGeometryPoint"}" Start Time: Mon Aug 05 09:51:35 2013 Running script JsonToFc... Converting JSON to FC... Completed script JsonToFc... Succeeded at Mon Aug 05 09:51:44 2013 (Elapsed Time: 9.49 seconds)


but publish to ArcServer succeeds and when trying to run it fails to create the feature class...
{  "error": {   "code": 400,   "message": "Unable to complete operation.",   "details": [    "Error executing tool."   ]  } }


And here is the content in the server logs:
Level Time Message Source Machine Code Time Elapsed User Name Process Thread Method Name
SEVERE Aug 5, 2013, 9:53:11 AM Error executing tool. ExtractDataTools/JsonToFc.GPServer <HOSTNAME>.<DOMAINNAME> 20010  anonymous 5212 7528 GPServerSync.CheckMessages
SEVERE Aug 5, 2013, 9:53:11 AM  Traceback (most recent call last): File "\\<FILESERVER>\<SHARE>$\directories\arcgissystem\arcgisinput\ExtractDataTools\JsonToFc.GPServer\extracted\v101\zipandship\JsonToFc.py", line 44, in res=arcpy.JSONToFeatures_conversion(json_file,fc) File "c:\program files\arcgis\server\arcpy\arcpy\conversion.py", line 430, in JSONToFeatures raise e ExecuteError: ERROR 000206: Cannot create FeatureClass 'C:\Users\<AGS SERVICE ACCOUNT>\AppData\Local\Temp\extractdatatools\jsontofc_gpserver\j631f8a7a49c34355a03361601e636c75\scratch\scratch.gdb\DATA_EXTRACT_130805_095310'. Failed to execute (JSONToFeatures). Failed to execute (JsonToFc). Failed to execute (JSON To Feature Class).


Any help is greatly appreciated.. I've tinkered with this for a few days with no success.  Tried changing the path of the FGDB to a custom location (not the arcpy environment workspaces) with no luck.  Made sure the service account has at least modify permissions to the output locations.  I can run these just from desktop. 

ArcGIS Desktop 10.2
ArcGIS Server 10.2
Portal for ArcGIS v 2.2 (ArcServer is federated with the portal)

Thanks!

Outcomes