BECS OData Service


This section is focused on explaining principles of using General BECS OData Service and its sample usage in BECS integration project, describing it in two major subsections:​​​​​​​

1 General BECS OData Service principle​​​​

2 How to use General BECS REST API Service in the project​​​​​​​

 

1 General BECS OData Service principle

1.1 What is OData?

OData (Open Data Protocol) is an OASIS standard that defines the best practice for building and consuming RESTful APIs. OData helps you focus on your business logic while building RESTful APIs without having to worry about the approaches to define request and response headers, status codes, HTTP methods, URL conventions, media types, payload formats and query options etc. OData also guides you about tracking changes, defining functions/actions for reusable procedures and sending asynchronous/batch requests etc. Additionally, OData provides facility for extension to fulfil any custom needs of your RESTful APIs.

OData RESTful APIs are easy to consume. The OData metadata, a machine-readable description of the data model of the APIs, enables the creation of powerful generic client proxies and tools. Some of them can help you interact with OData even without knowing anything about the protocol.

 

1.2 What is General BECS OData Service?

BECS is open and very powerful platform used in wide range of industrial areas and business scenarios. To increase possibility of using BECS we hardly working also on adaptation of different standards for communication and keep the flexibility and power of BECS integration Visual Modeling unchanged.

General BECS OData Service layer was designed as another general way how to start integration via REST API call for any integration project (after adaptation of standard REST, SOAP and graphQL).

BECS OData Service is the layer for using OData queries to retrieve BECS enabled/integrated data from any BECS integration solution.

 

1.2.1 General BECS OData Service in closer look

Please do not forget, that BECS is driven by integration visual projects (called BECS Integration Project or BECS IP). The major reason of adapting OData Service layer is to enable using of any standard BECS IP also via OData channel (request/response).

This will allow to integrate with any OData compliant system easily and use full power of BECS projects and connectors as well.

 

1.2.2 General architecture of BECS OData Service

In following picture, you can see the global architecture of BECS OData Service and its cooperation with standard BECS IP. Schema shows standard flow for OData requestor:

 

1​​​​​​​.2.2.1 Execution steps for standard OData interaction

Following picture in previous chapter the execution flows can be described:

      1. OData caller is querying BECS OData server with well formatted OData query
      2. ---------------BECS OData Server---------------
      3. BECS OData server is starting to execute external query in following steps:
        1. Validation of OData Query syntax – in this step is validated not only OData syntax, but also the implemented directives (BECS OData server has, of course, not adapted whole OData syntax – see later)
      4. Successfully validated OData request is analyzed to retrieve:
        1. List of data tables required to update from external system
        2. Query to apply on updated Data Tables
      5. Analyzed output is then encapsulated to proper BECS TCP request and BECS Server is called
      6. ---------------BECS Integration Service---------------
      7. BECS Received call into “Dispatcher Integration Project”
        1. This project will resolve what are the names of BECS DataReader integration projects assigned to Data Tables requested
        2. Dispatcher is execution all investigated BECS DataReader Integration Projects
          1. Each project is using related BECS Connectors to communicate with external systems
        3. Execution is returned to Dispatcher Integration Project to package all retrieved data from DataReader projects into one payload
      8. ---------------BECS OData Server---------------
      9. BECS OData Payload Formatter generate output in requested format (XML/json)
      10. Data are returned to called (OData Client)

 

​​​​​​​1.2.3 Details about OData directives enabled in BECS OData Service

OData syntax supports wide range of options and directives – see www.odata.org. Because not all of them are relevant for BECS integration purposes in following sections you can find implemented (supported) directives in BECS OData server.

 

1.2.3.1 ​​​​​​​Payload format

BECS OData Service supports both possible payload format (ATOM XML, JSON).

​​​​​​​

1.2.3.1.1 Default format

If not defined, BECS OData Service returned payload in AtomXML (see RFC 4287 - The Atom Syndication Format):

Request:

https://uks-qa-becs.bentley.com/BECS.Odata.Translator/api/odata/Customers

Response:

 

1.2.3.1.2 ​​​​​​​Directive “?format”

If required to switch payload to json format, use directive “?format=json”:

Request:

https://uks-qa-becs.bentley.com/BECS.Odata.Translator/api/odata/Customers?format=json

Response:

 

1.2.3.2 Metadata retrieve

 

1.2.3.3 Basic metadata

As standard in OData syntax by placing only endpoint URL, the basic metadata definition will be returned:

Request:

https://uks-qa-becs.bentley.com/BECS.Odata.Translator/api/odata/

Response:

 

1.2.3.4 Advanced metadata – “directive $metadata”

To get advance information about connected objects, BECS OData Server supports $metadata directive. In this advanced view is possible to see all details about attributes as well as keys definitions:

Request:

https://uks-qa-becs.bentley.com/BECS.Odata.Translator/api/odata/$metadata

Response:

​​​​​​​

1.2.3.5 Data retrieve

1.2.3.5.1 Simple Data Request

As defined in OData standards also BECS OData Service returned data via simple query request – just place name of the data object after root endpoint URL (data object listed from basic metadata request):

Please be aware, that Service EndPoint depends on machine where the service is installed, so it needs to be changed to proper architecture every time!

Request:

https://uks-qa-becs.bentley.com/BECS.Odata.Translator/api/odata/Customers

Response:

 

1.2.3.6 ​​​​​​​Field selection, directive “?select”

For retrieving only selected fields can be used “?select” directive.

Request:

https://uks-qa-becs.bentley.com/BECS.Odata.Translator/api/odata/Customers?&select=ContactTitle,ContactName

Response:

 

1.2.3.6.1 ​​​​​​​Data filtering Request

As defined in OData standards also BECS OData Service supports two ways of filtering:

 

​​​​​​​1.2.3.6.1.1 Using native filtering condition

By placing filtering condition in brackets after the data object name, BECS OData Service will return filtered data. In this syntax only Key Filed attributes can be used!

Request:

https://uks-qa-becs.bentley.com/BECS.Odata.Translator/api/odata/Customers(CustomerID='ANATR')

Response:

​​​​​​​

1.2.3.6.1.2 Using filtering by directive “$filter”

By directive $format can be defined sophisticated filtering

Request:

https://uks-qa-becs.bentley.com/BECS.Odata.Translator/api/odata/Customers?filter=CompanyName%20eq%20%27Alfreds%20Futterkiste%27

*in URL query above is formatted “ “ (space) as “%20” (standard web formatting)

Response:

 

​​​​​​​1.2.3.6.2 Data linking Request

As defined in OData standards also BECS OData Service supports easy linkage of data objects:

For example showing also all sales orders for selected customer (ANATR) use following query:

Request:

https://uks-qa-becs.bentley.com/BECS.Odata.Translator/api/odata/Customers(CustomerID='ANATR')/Orders

Response:

​​​​​​​

1.2.3.6.3 Data Paging

To support records sub-selection of payload can be used following directives:

 

1.2.3.6.3.1 ​​​​​​​Directive ?Top

For returning only TOP x records is possible to use directive “?top” – for example return of top 3 Customers:

Request:

https://uks-qa-becs.bentley.com/BECS.Odata.Translator/api/odata/Customers?top=3

Response:

 

1.2.3.6.3.2 Directive &skip

For starting from defined record is possible to use directive “&skip” – for example return of top 3 Customers, but skip the first one (=start from second):

Request:

https://uks-qa-becs.bentley.com/BECS.Odata.Translator/api/odata/Customers?top=3&skip=1

Response:

 

2 How to use General BECS REST API Service in the project

​​​​​​2.1 General intro

Based on general architecture diagram listed in chapter 1.2.2 General architecture of BECS OData Service is possible to call any BECS project.

 

2.2 Sample of calling

For example calling Equipments from SAP PM module via BECS we used:

Request:

https://uks-dev-becs.bentley.com/BECS_Odata/api/odata/V-301/DATA_SAP_EQUI_Data

Response: