Select to view content in your preferred language

GeoEvent Admin API: Creating a GeoEvent Defintion

344
0
12-04-2019 09:23 AM
EricIronside
Esri Regular Contributor
1 0 344

You can use the Admin API of GeoEvent to create or update new GeoEvent Definitions, but be sure to use the right JSON format.  When the API encounters an error when importing your definition, the error message can be a bit misleading/confusing.  To clarify this a bit, I'm collecting examples of what might go wrong on this page. I will update it if I find more.

Cannot deserialize instance ...

When posting your JSON to the API, you may encounter the following error message:

Cannot deserialize instance of `com.esri.ges.jaxb.geoeventdefinition.GeoEventDefinitionWrapper` out of START_ARRAY token\n at [Source: (org.apache.cxf.transport.http.AbstractHTTPDestination$1); line: 1, column: 1]

In this case it is tempting to see the word token and think security issues.  However, the key to this error message is the first part Cannot deserialize....  The JSON parser has tried to parse your JSON into a GeoEvent Defintion and failed.  The token it is referring to is a parsing/deserializing term related to token/value pairs.  In my specific case, my JSON was valid (as confirmed by an independent JSON LINT) so what could possibly be the problem?? It turns out my JSON GeoEvent Definition was encapsulated in square brackets, indicating I was posting an array of GeoEvent Definitions. 

[ { "guid": "12345678-9abcdefgh-1234-abcdefghijkq", "name": "c-in", "owner": "admin", "accessType": "editable", "fieldDefinitions": [ { "name": "cId", "type": "String", "cardinality": "One", "fieldDefinitions": [] }, { "name": "geometry", "type": "Geometry", "cardinality": "One", "fieldDefinitions": [], "fieldDefinitionTag": [ "GEOMETRY" ] } ] } ]

The parser attempted to put the array object into a single GeoEvent Definition, causing the failure (it found a JSON Array token rather than a JSON Object token).  The quick fix was to remove the outside square brackets and everything worked as expected.

About the Author
Esri Professional Services Real-Time GIS Team GeoEvent Sr. Product Enginner