JSON format for receiving and providing data using interfaces

JSON format for receiving and providing data using interfaces

Interfaces require a fixed data structure. This article describes the structure of the JSON format.

Data structure for receiving data from an external application

The data structure used to upload element data is similar for both the custom interface configured with a power user (via upload) and the custom interface configured with an external application (via API request). The code below describes the structure needed to upload data to Relatics:

{
   "TypeElementPlural": [
      {
         "@externalid": "Unique value",
         "PropertyName": "Value",
         "PropertyName": Number,
         ...
         "RelationName": [
            {"@id": "element ID"},
            {"@id": "element ID"},
            ...
         ]
      },
      ...
   ]
}

Once the data is processed, a response json is returned containing the externalid and a link to the corresponding element. The code below describes the structure of this response:

{
   "TypeElementPlural": [
      {
         "@externalid": "Unique value",
         "@relaticselementurl": "link to the corresponding element"
      },
      ...
   ]
}

Notes:

  • The italic texts should be replaced by data representing your SE model in Relatics.
  • Every JSON object in “TypeElementPlural” needs a JSON property “@externalid” that should be populated with a unique value. Relatics stores these values in a system property for the corresponding elements. When an update is presented, Relatics uses the “@externalid” to determine if an element needs to be created, updated, or deleted.
  • The JSON property “@externalid” allows a value with a maximum length of 450 characters.
  • The values of the JSON properties ​​must follow the same rules that manual entry enforces, specific to the property type in which the information is stored.
  • Dates must be structured as strings like “YYYY-MM-DD”, where YYYY corresponds to the year, MM corresponds to the month, and DD corresponds to the day.
  • The decimal sign of number values has to be a point.
  • "element ID" should be filled with the value of the Relatics element ID for project elements. For reference elements the Displayname or PropertyAsIdentifier value is used for externally managed type relations.
  • Relations are always stored as an array, even if the cardinality of the relation is configured as single.
  • Characters that are not letters or numbers in JSON names are escaped. See the section below for further details.
  • Elements not supplied in the request body will be deleted.

Example of the JSON data:

Request:

{
   "Persons": [
      {
         "@externalid": "43530759",
         "First_x0020_name": "Ace",
         "Last_x0020_name": "Whitney",
         "Date_x0020_of_x0020_birth": "1980-04-09",
         "works_x0020_for": [
            {"@id": "ORG-1"}
         ]
      },
      {
         "@externalid": "d390874b",
         "First_x0020_name": "Diogo",
         "Last_x0020_name": "Goldsmith",
         "Date_x0020_of_x0020_birth": "1964-11-23",
         "works_x0020_for": [
            {"@id": "ORG-7"}
         ]
      }
   ]
}

Response:

{
   "Persons": [
      {
         "@externalid": "43530759",
         "@relaticselementurl": "https://myenvironment.relatics.com/deeplink?lt=1&ws=755053b0-ba42-494a-b467-8c2cf408be65&el=PRS-1"
      },
      {
         "@externalid": "d390874b",
         "@relaticselementurl": "https://myenvironment.relatics.com/deeplink?lt=1&ws=755053b0-ba42-494a-b467-8c2cf408be65&el=PRS-2"
      }
   ]
}

Data structure for providing data to an external application

The Providing method should be used to retrieve data from Relatics by an external application. The data in the response body is determined by the script in the interface. The code below shows the structure that Relatics returns:

{
   "Data": [
      {
         "@type": "TypeElementName",
         "@Id": "Relatics id",
         "PropertyName": "Value",
         "PropertyName": "Value",
         ...
         "Relation": [
            "@type": "TypeElementName",
            "@Id": "Relatics id",
            "PropertyName": "Value",
            "Relation": [
               "@type": "TypeElementName",
               "@Id": "Relatics id",
               ...
            ]
         ],
         ...
      },
      ...
   ]
}

Notes:

  • Relation is a concatenation of the relation name, a colon, and the element name, e.g. is_responsible_for:Action.
  • A type element with ownership in an external application gets, by default, an extra property @externalId. This property contains the unique ID by which this element is known in the external application.
  • Characters that are not letters or numbers in JSON names are escaped. See the section below for further details.

Example of the JSON data:

{
  "Data": [
    {
      "@type": "Person",
      "@id": "PER-1",
      "Date_of_birth": "1980-04-09",
      "First_name": "Ace",
      "Last_name": "Whitney",
      "works_for:Organisation": [
        {
          "@type": "Organisation",
          "@id": "ORG-2",
          "Name": "City of Munich"
        }
      ]
    },
    {
      "@type": "Person",
      "@id": "PER-9",
      "Date_of_birth": "1964-11-23",
      "First_name": "Diogo",
      "Last_name": "Goldsmith",
      "works_for": [
        {
          "@type": "Organisation",
          "@id": "ORG-7",
          "Name": "RailDesign Inc."
        }
      ]
    }
  ]
}

Deprecated: Data structure for interfaces for providing IDs and display names (as input for external relations)

The Providing method should be used to retrieve IDs and display names from Relatics by an external application. The code below shows the structure that Relatics returns:

{
   "TypeElementPlural": [
      {
         "@Id": "Relatics id",
         "@DisplayName": "Value"
      },
      ...
   ]
}

Notes:

  • The response is limited to the ID and display name of the elements.
  • Characters that are not letters or numbers in JSON names are escaped. See the section below for further details.

Example of the JSON data:

{
   "Persons": [
      {
         "@Id": "PER-1",
         "@DisplayName": "Konnor Carney"
      },
      {
         "@Id": "PER-6",
         "@DisplayName": "Ace Whitney"
      }
   ]
}

Escape non-letter or number characters

When one of the following characters is used in the TypeElementPlural, PropertyName, or RolName, the representing escape characters must replace this character:

Character Escape character
& _x0026_
– _x002D_
( _x0028_
) _x0029_
, _x002C_
[space] _x0020_