Inbound REST Web Services

This topic provides more information about the product's support of REST services using IWS.

The REST engine checks the Accept-Language header and attempts to find a supported language whose locale matches the referenced language. If found, the web service response returns any translatable data in that language. Note that if no supported language is found for the languages provided in the Accept-Language header, the system uses the language of the user that submitted the request.

IWS REST records are marked with a REST engine version of 1.0 or 2.0. Version 2.0 is the version used for new services. Version 1.0 is introduced for backward compatibility. Some of the system behavior differs based on the version of the REST service. The sections below highlight cases where this occurs.

HTTP Method and Parameters

When defining operations for inbound REST web services, the product supports the HTTP methods of Get, Patch, Post, Put, and Delete. Note that the product's support of these various HTTP methods are a means of communicating the purpose of the web service to the outside world. However, the actual behavior of the REST web service is driven by the behavior of the underlying schema based object (business object, business service or service script). For example, you may configure the HTTP Method of "Put" for an operation that references a service script that just retrieves a record. The product is not able to detect this type of discrepancy. Configuration users should carefully consider the correct method to use based on the logic of that service.

For operations that reference a business object, the transaction type must be provided. The REST syntax doesn't support defining the transaction type at runtime. There are some basic validation checks in this case related to the transaction type and the HTTP method. For example, a Get method only makes sense with the Read transaction type.

Note: Using the transaction type Change requires all values to be passed in. Using the transaction type Update allows the web service to pass only the primary key and the values to be updated. All other elements will retain their existing values.

You may additionally define parameters. For each parameter, you define an external reference to the element, which is how this parameter is exposed to the external callers and is defined in the API specification. Each of these parameters is mapped to the XPath of the schema element from the underlying business object, business service or service script. For each parameter, you indicate if it is a Path parameter or a Query parameter.

  • Path parameters are parameters that are part of the endpoint and are required. Each path parameter must be included in the operation's URI component surrounded by curly brackets.

  • Query parameters are optional. They are not part of the endpoint but rather are included in the endpoint URL after a question mark, followed by name value pairs.

Refer to the URL section below for examples of path and query parameters in the sample URLs.

URL Composition

When building the endpoint URL for a REST service, there are three main parts that make up the full URL.

  • The first part is the one that is environment specific. This will differ for an on premise implementation as compared to a cloud implementation. Both will have the host and the port and then additional components that identify the environment.

  • The second part is a hard coded path designated by the product, namely "/rest/apis".

    These two parts of the URL are defined in the substitution variable F1_​REST_​BASE_​URL. This is defined when initializing your environment. Refer to the Server Administration Guide for more information.

The remaining part of the URL is built dynamically based on configuration for each IWS and its operations. The components are "/ownerURIComponent/resourceCategoryURIComponent/iwsURIComponent/operationURIComponent"

  • The owner URI component is taken from the owner flag of the inbound REST web service. A special extendable lookup (Owner Configuration for REST Services) defines this component for each owner flag.

  • Each Inbound REST Web Service must reference a resource category. This category is used to associate related web services to a common category of resources. For multiple IWS records linked to the same resource category, external catalogues can use this information to group together related web services. The resource category is an extendable lookup and the URI component is an attribute of this record.

  • Each REST IWS record defines a URI component that serves as an external identifier of this IWS record. The value must be unique within a given owner flag.

  • Each operation must define the HTTP Method and optionally a URI component. When defining path parameters, the path parameters must be included in the URI component using curly braces.

In all cases, the URI component must begin with a slash ('/').

The following are some examples of the dynamic portion of the URL for a REST service. The last example illustrates the use of a query parameter.

IWS Name

URI Component

Owner

URI Component

Resource Category

URI Component

Operation HTTP Method

URI Component

Dynamic URL Component Run Time Example

c1rateCalculation

/rateCalculation

C1

/customer

C1-RATES

/rates

Post

/

../customer/rates/rateCalculation/ ../customer/rates/rateCalculation/

w1WorkActivity

/workActivity

W1

/asset

W1-WORK

/work

Get

/{activityId}

../asset/work/workActivity/{activityId} ../asset/work/workActivity/5798165498

w1WorkActivity

/workActivity

W1

/asset

W1-WORK

/work

Patch

/scheduleWindow/{externalSystem}/{activityId}/{windowStartDateTime}

../asset/work/workActivity/scheduleWindow/{externalSystem}/{activityId}/{windowStartDateTime} ../asset/work/workActivity/scheduleWindow/MY-COMPANY/5798165498/20190101

CM-AccountActivityHistory

/accountActivityHistory

CM

/cm

CM-ACCT-INFO

/accountInformation

Get

/{accountId}

../cm/accountInformation/accountActivityHistory/{accountId} ../cm/accountInformation/accountActivityHistory/123456789?activityId=5468976

Payload Format

REST services support receiving a request payload in XML or JSON format and returns the payload in either XML or JSON. The default format returned depends on the value of the REST Engine Version.

  • Version 2.0 services assume JSON format as the default. The default can be overridden by providing an accept header of application/XML.

  • Version 1.0 services assume XML format as the default. The default can be overridden by providing an accept header of application/JSON.

Root Node for JSON Format

Version 2.0 services with the JSON formatted payload do not accept in the request or return in the response any root node around the payload. The following is an example of the response of a REST call for a version 2.0 service:

{
   "batchJobId": "string",
   "requestSuccessful": "string"
}

Version 1.0 services with the JSON formatted payload expect a root node in the request and return one in the response. The following is an example of the response of a REST call for a version 1.0 service:

{
  "F1CnclBatJob": {
    "batchJobId": "string",
    "requestSuccessful": "string"
 }
}

The Open API Specification visible on the inbound web service maintenance page displays the expected format based on the record's REST engine version when viewing the specification.

Data Type Format in JSON

In JSON format, strings are surrounded by quotes and numbers and Boolean data do not have quotes. All services for REST engine version 2.0 follow this standard. Originally services that are REST engine version 1.0 were incorrectly treating numbers and Boolean data as strings and returning the data with quotes. This has been corrected.

To accommodate any integration that may have worked around the behavior for version 1.0 services, the system provides the ability to identify inbound web services that are exceptions to this rule. For any inbound web service identified as an exception, the system continues to treat numbers and Boolean data as strings in JSON responses. To add one or more IWS records to the exception list:

  • Go to Feature Configuration.

  • Look for an existing feature configuration with the feature type External Messages.  If one does not exist, create one.

  • Add an option for the option type IWS JSON Data Type Exceptions.

  • In the option value, indicate the IWS record that is an exception.  Note that multiple options for the option type may be added.  Additionally, the option value supports a comma delimited list.

External Facing Schema

By default the schema of the underlying service (for example, service script, business object or business service) is also the schema for the REST inbound web service operation and acts as both its Request and the Response schema. The product provides the ability to define an explicit schema for a REST inbound web service (IWS) operation, allowing a user to adjust the schema for an external facing consumer. The IWS operation schema also supports some special configuration that allows additional features to be defined only for the IWS operation schema.

The operation schema supports the following capabilities:

  • Declaring whether an element belongs only to the request schema, only to the response schema, both (default) or excluded altogether. This is used to establish a clear separation between request and response schema definitions.

  • Assign a different element name to an internal element. This allows the internal service element name to more closely align to internal references to the element, if needed. The external facing element name can be different allowing for a more readable schema.

  • Introduce specialized elements that support links and other types of structural standards in a way that does not impact internal service processing.

Refer to Web Service Schema Nodes and Attributes for more information.

The REST servlet uses the request and response schemas to map elements to and from the internal schema.

Note: While the caller should only provide elements defined by the request schema, the application does not filter out extraneous elements. Assumption is that the internal service is designed to ignore such elements. However, only elements defined by the response schema are included in the response.

Open API Specification Documentation

The following documentation information may be provided for an Inbound Web Service:

  • Short and detailed description for each operation.

  • Help text may be provided for individual elements. The same text can be shared across multiple elements across all operations of the Inbound Web Service. If an element is not associated with help text then its internal field’s label is used instead.

  • Sample request and response documents may be provided for each operation.

  • Operations may be associated with a sequence number that controls the order in which they appear in the Open API Specification. 

Note: Detailed descriptions and element related help text are not translated since the published catalogue for base product APIs is in English language only.