I am receiving this error below when I try to retrieve the getJSON variable:
Python Exception <Exception>: Unable to update feature service layer definition.
Object reference not set to an instance of an object.
(Error Code: 400)
Error encountered while calling function `processFeature'
PythonCaller_3 (PythonFactory): PythonFactory failed to process feature
PythonCaller_3 (PythonFactory): A fatal error has occurred. Check the logfile above for details
A fatal error has occurred. Check the logfile above for details
JSONFormatter (JSONFormatterFactory):
This is the code in PythonCaller (simplified for readability):
import fme
import fmeobjects
from arcgis.gis import GIS
def processFeature(feature):
getJSON = feature.getAttribute('JSON')
gis = GIS(profile='username')
lyr = gis.content.get('item_id').layers
for lyr in gis.content.get('item_id').layers:
lyr.manager.update_definition(getJSON)
I know getJSON is giving me issues because if I replace lyr.manager.update_definition(getJSON) with lyr.manager.update_definition({ "fields" : { "name" : "FIELDNAME", "domain" : { "type" : "codedValue", "name" : "DOMAINNAME" : n { "name" : "TEST", "code" : "TEST" }, { "name" : "TEST1", "code" : "TEST1" }, { "name" : "TEST2", "code" : "TEST2" } ] } } ] } then it works.
Essentially, I like to create a JSON object in an attribute using JSONTemplater and put it into PythonCaller so I don't have to hardcode the JSON object.
Thanks in advance!