REST API

REST API: Overview

APIs

All API data sources are defined in one file: schema/ab-products/common/api/ab-api-datasources.axvw

Data source names must follow this convention:

Api_[ dataSourceName ]_v[ version ]

  • version is a version of the data source. The first implementation of the data source has version = 1. Each change to the data source implementation that’s not backwards-compatible increments the version.
  • dataSourceName is a descriptive name of the data source.

Example:

  • Api_HrEmLocations_v1 (initial version)
  • Api_HrEmLocations_v2 (version 2 which provides additional functionality and changes the data format)

Authentication

All REST API calls must be authenticated per REST API - System Integrator Guide .

Cross-origin resource sharing (CORS)

The APIs can be called from web applications loaded from a different domain than the Web Central domain. By default, all APIs enable CORS. The current implementation uses Sprint framework’s @CrossOrigin annotations per REST controller class: https://docs.spring.io/spring/docs/4...html/cors.html .

CORS exceptions can be added either in the REST API source code, or by implementing a custom filter: https://stackoverflow.com/questions/...pring-security .

Request and response data objects

Callers can pass data objects (e.g. service requests) to API endpoints, and can also query data objects from API endpoints. All data objects are passed in the HTTP request body, or returned in the HTTP response body, using Content-Type:application/json .

If the API endpoint is designed to accept or return a single object, this is a JSON object.

If the API endpoint is designed to accept or return many objects, this is a JSON array with 0 or more elements.

Object property names must match Archibus schema.

Example:

{ "activity_log_id": 8658, "prob_type": "HVAC", "phone_requestor": "555-5555", "status": "CANCELLED" }

Specifying a query filter

Callers can specify a filter for the query in the HTTP request body. The filter can contain one or more clauses:

[ { fieldName: 'bl_id', filterValue: 'HQ%', filterOperation: 'LIKE' }, { fieldName: 'fl_id', filterValue: '17', filterOperation: '=' } ]

Filter clauses are combined using AND by default. Optionally, you can specify relative operation to combine clauses using OR.

Example: This filter returns requests in the Approved status made by AFM or AFM-MOD

[{ "fieldName": "status", "filterValue": "Approved", "filterOperation": "=" },{ "fieldName": "requestor", "filterValue": "AFM", "filterOperation": "=", "relativeOperation": "AND" },{ "fieldName": "requestor", "filterValue": "AFM-MOD", "filterOperation": "=", "relativeOperation": "OR" }]

For numeric and date fields, the caller can specify open or closed range:

{ fieldName: 'area', filterValue: '100', filterOperation: '>=' }

Specifying paging

For APIs which return multiple records, such as GET /api/v1/data/ or GET /api/v1/service-desk/requests/, callers can retrieve one page of data at a time by specifying these query parameters:

  • pageStart : 0-based index of the first row.
  • pageSize : number of rows to fetch, 0 to fetch all rows.

Date and time values

The APIs return date and time values formatted as strings in the ISO 861 format.

"bl.date_bl": "2018-10-31T04:00:00Z"