How can we help?

Searching:

0 results found

Schema Definitions/Post

POST /odata/schemaDefinitions
 

Description:

To create a new Schema Definition.
 

Request – Schema Definitions/Post
Property Type Description Mandatory
name String The name of the schema
parserType String/Enum Parser Type – the type of the incoming payload.

  • JsonParser – the payload is JSON
  • StringParser – the payload is String.
  • LorawanParser – the payload is Lorawan.
schemaOptions Object The definition of the schema.
schemaOptions/bulk Object For use cases where the incoming payload is array.
schemaOptions/bulk/porpertyName String The property that indicates the array in the payload.
schemaOptions/bulk/isEnabled Boolean Default = true, should it parse the payload as array. If no property name is declared, it will consider the json as array on the root level.
schemaOptions/autoDiscovery Object Auto Discovery is the option where new devices are added automatically to Axonize upon their first event arrival.
schemaOptions/autoDiscovery/enabled Boolean Default = true, Is Auto Discovery enabled.
schemaOptions/autoDiscovery/customIdRegexFilter String Regex to filter the creation of specific devices. The regex is applied on the device customId.
schemaOptions/autoDiscovery/customFunction String Function that runs as part of the auto discovery action.
schemaOptions/decryptPayloadFunction String JavaScript function that will decode the incoming payload before it enters the schema parsing.
schemaOptions/constants List of Schema Constant objects A key value object that includes constant for the schema to use.
schemaOptions/constants/key String The key of the constant
schemaOptions/constants/value String The value of the constant
jsonSample Object Payload sample of the schema
jsonSample/content String The json content.
jsonSample/name String The name of the sample.
jsonSample/updateDate String The date where the sample was updated.
schema List of SchemaObject Objects
schema/attributePath String The name of the json key.
schema/convertInfo Object
schema/convertInfo/functionType String/Enum The type of functions

  • undefined.
  • customFunction – user defined function.
  • multiply – multiply the value by the specified parameter.
  • decToHex – convert the value from decimal to hex.
  • hexToDec – convert the value from hex to decimal.
  • epochToDateTime – epoch date time to iso8601 format.
  • substring – extract the characters of the value between the two specified parameters.
schema/convertInfo/parameters List of Strings The parameters for the predefined function.
schema/covertInfo/customFunction String JavaScript function.
schema/actionType String/Enum The Axonize type of json key

  • Event – the json key is Event.
  • Patch – the json key that should patch the device property.
  • CustomId – The external device identifier.
  • Datetime – the json key that indices the event time.
schema/event Event Schema Object Describes how to build the event.
schema/event/name String The event name.
schema/event/typeCode Integer The event type code.
schema/event/unit String The event unit.
schema/patch Patch Schema Object The name of the property to patch in the device.

 

Example JSON Devices/Post Request

curl ‘https://api.axonize.com/odata/schemaDefinitions’  -H ‘Authorization: Your token’ -H ‘Content-Type: application/json;charset=UTF-8’ -H ‘appId: 9b96eab8-fa25-4549-925d-da8ecf9a1234’ –data-binary ‘{“jsonSample”:{“name”:”payload.json”,”content”:”{\”serial\”:\”1234\”,\”temp\”:34}”,”updateDate”:”2019-12-17T15:08:20.115Z”},”parserType”:”JsonParser”,”schema”:[{“attributePath”:”serial”,”actionType”:”CustomId”,”convertInfo”:{“functionType”:null,”parameters”:[]}},{“actionType”:”Event”,”event”:{“name”:”Temperature”,”typeCode”:7},”attributePath”:”temp”}],”name”:”usfhzq”}’ –compressed
 

Example JSON Devices/Post Response

 

Status 201 – Created

{“@odata.context”:”http://10.10.2.103/odata/$metadata#SchemaDefinitions/$entity”,”name”:”usfhzq”,”parserType”:”JsonParser”,”id”:”5df8ef8be3b0c7194448030d”,”appId”:”9b96eab8-fa25-4549-925d-da8ecf9a9b34″,”createDate”:”2019-12-17T15:08:59.5117694Z”,”createUser”:”1234″,”updateDate”:”2019-12-17T15:08:59.5117694Z”,”updateUser”:”1234″,”schema”:[{“attributePath”:”serial”,”actionType”:”CustomId”,”convertInfo”:{“functionType”:null,”parameters”:[],”customFunction”:null},”convertPipeline”:[],”event”:null,”patch”:null},{“attributePath”:”temp”,”actionType”:”Event”,”convertInfo”:null,”convertPipeline”:[],”event”:{“name”:”Temperature”,”typeCode”:7,”unit”:null},”patch”:null}],”options”:null,”jsonSample”:{“content”:”{\”serial\”:\”1234\”,\”temp\”:34}”,”name”:”payload.json”,”updateDate”:”2019-12-17T15:08:20.115Z”}}