Jamio openwork REST Gateway

The Jamio openwork REST gateway exposes Web APIs to access services from Jamio applications.

 

Authentication

Jamio services always require authentication, which can be accomplished in two ways:

1)    A new session can be created (POST Session), then the Token returned in the Session object can be passed in the Token header in the next invocations, followed by a DELETE Session/current to close the session

2)    Login information (IdentityRepositoryName, UserName, Password and optionally Source) can be passed in each invocation header

 

Content type

The content-type header must be application/json where not otherwise specified (uploads require a multipart/form-data content-type).

 

Optional repositoryId

Most invocations begin with the optional {repositoryId} parameter; if not specified, it is taken from the current session; for example:

GET {repositoryId}/Data/{id}

can also be invoked as

GET Data/{id}

where the repositoryId is taken from the current session.

 

Date format

Dates must be expressed in ISO 8601 format; for example: "2018-02-15T00:00:00+01:00".

 

 Type specification

Type specification (through the “$type” meta-property) in the JSON body structure is only needed when the value doesn’t match the expected complex type; this typically happens when the expected type is object (such as the Fields property in the following example), or when the value type is a specialization of the expected type (such as a CustomEvent passed for a property of expected type EventMessage):

{

  "$type": "openwork.Event.CustomEvent, openwork.Base",

  "ModelReference": {

    "$type": "openwork.Base.NamedReference, openwork.Base",

    "Name": "TestCustomEvent",

    "Url": "/B71AF61F730D410EB9DCA56A009E89D5/Model/AFB859E9178C4E0DB8BAA6CC00D269D4",

    "Type": 149

  },

  "Fields": {

    "$type": "openwork.Information.FieldDictionary, openwork.Base",

    "Text field": "Text content",

    "Date field": "2016-12-13T15:09:59.4524544+01:00"

  }

}

 

Error information

When an error occurs, the Response.ReasonPhrase contains detailed information on the error, and Response.Content contains the JSON serialization of a dictionary containing the following items:

“ErrorCode” (String)

“ErrorMessage” (String)

 

For example:

 

Response.ReasonPhrase: “I seguenti fatti sono falsi: OrganizationName di Organization deve essere non nullo - Name di Organization deve essere non nullo - Validazione della risorsa fallita.”

Response.Content:

{

  "ErrorCode": "ERR_ValidationFailed",

  "ErrorMessage": "Validazione della risorsa fallita."

}

 

 Ordering criteria

A OrderingCriteria is a collection of FieldName/OrderingType pairs; for example, to specify an ordering by “Price” (DESCending) and “Name” (ASCending):

"OrderingCriteria": {

    "Price": "DESC",

    "Name": "ASC"

  }

 

 Filters

A SimpleFilter is a collection of FieldName/FieldValue pairs to constrain a search, always in AND; for example, to specify (“InStock” = true) AND (“Category” = “BOOKS”):

"SimpleFilter": {

  "InStock": true,

  "Category": "BOOKS"

}

 

 

A complex filter can be specified through the following structures:

 

Filter

{

   string Subject

   string Predicate

   bool NegatePredicate

   object Complement

}

 

or

 

FilterGroup

{

   List<object> Filters

   string Operator

}

 

where:

 

Filters can contain objects of type Filter or FilterGroup.

 

Operator can be “AND” (default) or “OR”.

 

Subject is the field name (a catalog column).

 

Complement is the condition value.

 

NegatePredicate can be used to negate the condition, if set to true (defaults to false).

 

Predicate can be one of the following:

·         “Contains”

·         “EqualsTo”

·         “BeginsWith”

·         “IsReferenceOf”

·         “IsGreaterThan”

·         “GreatherThanOrEqual”

·         “IsLessThan”

·         “LessThanOrEqual”

 

Predicates for catalog column type:

 

String, Memo:

·         “Contains”

·         “EqualsTo”

·         “BeginsWith”

 

Reference:

·         “Contains” (refers to the reference Name, Complement is a String)

·         “EqualsTo” (refers to the reference Name, Complement is a String)

·         “BeginsWith” (refers to the reference Name, Complement is a String)

·         “IsReferenceOf” (refers to the whole reference, Complement is a NamedReference)

 

Numeric (Integer, Float, Decimal):

·         “EqualsTo”

·         “IsGreaterThan”

·         “GreatherThanOrEqual”

·         “IsLessThan”

·         “LessThanOrEqual”

 

DateTime:

·         “EqualsTo”

·         “IsGreaterThan”

·         “GreatherThanOrEqual”

·         “IsLessThan”

·         “LessThanOrEqual”

 

Boolean:

·         “EqualsTo”

 

 

Example of JSON body with a SimpleFilter:

 

{

  "ModelUrl": "/B71AF61F730D410EB9DCA56A009E89D5/Model/0155AA109B4044479E24A78900F5DCA7",

  "PageSize": 20,

  "PageNumber": 1,

  "SimpleFilter": {

    "InStock": true,

    "Category": "BOOKS"

  },

  "OrderingCriteria": {

    "Price": "ASC"

  }

}

 

 

Example of JSON body with a Filter:

 

{

  "ModelUrl": "/B71AF61F730D410EB9DCA56A009E89D5/Model/0155AA109B4044479E24A78900F5DCA7",

  "PageSize": 20,

  "PageNumber": 1,

  "Filter": {

    "Filters": [

      {

        "Subject": "Stock",

        "Predicate": "IsLessThan",

        "NegatePredicate": false,

        "Complement": 10

      },

      {

        "Filters": [

          {

            "Subject": "ForChildren",

            "Predicate": "EqualsTo",

            "NegatePredicate": false,

            "Complement": true

          },

          {

            "Subject": "Category",

            "Predicate": "EqualsTo",

            "NegatePredicate": false,

            "Complement": "BOOKS"

          }

        ],

        "Operator": "AND"

      }

    ],

    "Operator": "OR"

  },

  "OrderingCriteria": {

    "Price": "DESC",

    "Name": "ASC"

  }

}

 

 

Filters and OrderingCriteria can be applied on the Fields exposed in the catalog; filters can also be applied on the catalog item “Name”.

For example, for a Notification catalog…

 

{

  "Name": "Notifiche",

  "ItemList": [

    {

      "Name": "Debug",

      "Type": 157,

      "Url": "/B71AF61F730D419EB9DCA55A009A89D5/Notification/630BDC0B827F4313873BA89300D1E24E",

      "Fields": {

        "Subject": "Debug",

        "Source": "Process_A1",

        "From": {

          "$type": "openwork.Base.NamedReference, openwork.Base",

          "Name": "System",

          "Url": "/0/Identity/0",

          "Type": 115

        },

        "Message": "Step 2 OK",

        "ReceivedDate": "2018-02-26T12:43:15",

        "Unread": true

      }

    },

    {

      "Name": "Debug",

      "Type": 157,

      "Url": "/B71AF61F730D419EB9DCA55A009A89D5/Notification/EE2A424612E74EC0A272A89300B16EC8",

      "Fields": {

        "Subject": "Debug",

        "Source": "Process_A1",

        "From": {

          "$type": "openwork.Base.NamedReference, openwork.Base",

          "Name": "System",

          "Url": "/0/Identity/0",

          "Type": 115

        },

        "Message": "Step 1 OK",

        "ReceivedDate": "2018-02-26T12:42:31",

        "Unread": true

      }

    }

  ],

  "EntityType": {

    "$type": "openwork.Base.InternalType, openwork.Base",

    "Type": 157

  },

  "TotalCount": 2,

  "PageNumber": 1,

  "PageSize": 50

}

 

…filters can be specified on “Name”, "Subject", "Source", "From", "Message", "ReceivedDate" and "Unread",

while ordering criteria can be specified on Subject", "Source", "From", "Message", "ReceivedDate" and "Unread".