SmartConnector RESTful EWS Gateway
SmartConnector RESTful EWS Gateway
EWS Gateway
Buildings Labs
SmartConnector RESTful EWS Gateway
1 Support.................................................................................................................................................. 3
2 Revision History .................................................................................................................................... 3
3 Overview ............................................................................................................................................... 4
3.1 Scope ............................................................................................................................................. 4
3.2 What is SmartConnector RESTful EWS Gateway? ........................................................................ 4
4 REST Extension Framework................................................................................................................... 6
4.1 Authentication .............................................................................................................................. 6
4.2 RESTful URLs.................................................................................................................................. 6
4.3 Self- Documenting......................................................................................................................... 6
4.4 Filtering, Sorting, and Paging ........................................................................................................ 6
4.5 HTTP Status Codes ........................................................................................................................ 7
4.6 Response Headers......................................................................................................................... 7
4.7 Layered System ............................................................................................................................. 7
4.8 Rate Limiting ................................................................................................................................. 8
5 RESTful EWS Gateway ........................................................................................................................... 9
5.1 Data Providers ............................................................................................................................... 9
5.1.1 MongooseEwsRestProvider .................................................................................................. 9
5.1.2 SoapEwsRestProvider ........................................................................................................... 9
5.1.3 SboEwsRestProvider ............................................................................................................. 9
5.2 Provisioning and Configuring Endpoints ....................................................................................... 9
5.2.1 Adding REST Endpoint ........................................................................................................... 9
5.2.2 Configuring REST Endpoint ................................................................................................. 10
5.2.3 Complete Configuration ...................................................................................................... 14
5.3 Resources and Actions ................................................................................................................ 14
5.3.1 AlarmEvents ........................................................................................................................ 14
5.3.2 AlarmEventTypes ................................................................................................................ 18
5.3.3 Alarms ................................................................................................................................. 21
5.3.4 Containers ........................................................................................................................... 29
5.3.5 Notifications ........................................................................................................................ 35
5.3.6 Root ..................................................................................................................................... 38
Document : Revision Revision date Page
TDS-M- EWSRESTGATEWAY-US.BU.N.EN.12.2017.02.30.CC 2 8/16/2018 Page 1 of 76
SmartConnector RESTful EWS Gateway
1 Support
Schneider Electric provides branch and channel partners with planning and implementation assistance
for Buildings Labs. To request help, send an email to Product Support specifying the solution name and
the type of assistance you require. Product Support will relay your request to the appropriate support
team.
2 Revision History
Date Author Revision Changes Made
2/21/2017 MRS 1 Initial release.
12/15/2017 MRS 2 Updated for v2.3
08/16/2018 JMB 3 Updated for v2.4
© 2017 Schneider Electric. All Rights Reserved. Schneider Electric, StruxureWare, SmartStruxure solution, and
EcoStruxure are trademarks owned by Schneider Electric Industries SAS or its affiliated companies. All other
trademarks are the property of their respective owners.
3 Overview
3.1 Scope
This document is intended as a guide for developers wishing to exchange data via a SmartConnector
enabled REST endpoint using an API and data model based on the Schneider Electric EcoStruxure Web
Services (EWS) data model. This document assumes the reader is familiar with the EcoStruxure Web
Service Specification, has the requisite knowledge in consuming a RESTful HTTP endpoint, and is
sufficiently proficient in the programming language they are developing in.
This document will not cover the details pertaining to installation, monitoring, and control of
SmartConnector in a runtime environment. That information can be found in SmartConnector
Installation and Configuration Guide. Configuration instructions, as they pertain to REST endpoints will
be covered.
Furthermore, this document will not cover the details in consuming SmartConnector’s libraries for the
purpose of authoring customized middleware applications (SmartConnector Extensions) to run in
SmartConnector. That information can be found in SmartConnector Developers Guide.
Simple Object Access Protocol (SOAP) and Representational State Transfer (REST) should never be
compared directly (yet they often are); SOAP is a protocol while REST is an architecture.
REST was first described by Roy Fielding in his 2000 PhD dissertation on network based software
architectures. From Fielding’s own dissertation, the major characteristics of REST systems are: client-
server based, stateless, cacheable for performance optimization, with layered abstractions.
SOAP was designed by Winer, Box, Atkinson, and Al-Ghosein for Microsoft in 1998 as a messaging
protocol. It was submitted to IETF in 1999 and in 2003 (as v1.2) became a W3C recommendation. SOAP
has three major characteristics: extensibility, transport layer neutrality, and programming model
independence. Lacking from the specification is security and routing definitions.
EWS is Schneider Electric’s SOAP interface for system to system data exchange. From the EWS
specification itself:
“EWS defines a common interface for the exchange of data between systems in EcoStruxure-targeted
solutions. Products and systems adhering to the specification can quickly and easily exchange
information such as state, historical and alarm data. EWS also supports the exchange of system
information, for example, hierarchical structure and metadata. It does not, however, support the ability
for one system to create new objects and data structures in another system.”
The next logical question is, “If a SOAP API already exists, why do we need a RESTful one?” The honest is
answer is you don’t. If you are comfortable developing applications using a SOAP client against a EWS
server then you can continue to do so. However, if you prefer to move away from SOAP to a more
portable lightweight abstraction, which can provide full Create, Retrieve, Update, and Delete capabilities
(CRUD), then this gateway is for you.
A frequently requested feature for SmartConnector was to serve EWS data in a RESTful manner. This
request was followed closely by requests for SmartConnector to provide an infrastructure which allowed
SmartConnector Developers to author and subsequently host custom RESTful APIs for others to
consume.
SmartConnector now provides a REST Extension framework along with a specific implementation of it:
the SmartConnector RESTful EWS Gateway.
• Authentication
• RESTful URLs
• Self-Documenting
• Filtering, Paging, and Sorting
• HTTP status codes
• Response headers
• Layered System
• Rate Limiting
4.1 Authentication
RESTful APIs are stateless. This means that requests should never rely on sessions or cookies. Rather,
each request should include credentials in the form of access tokens. SmartConnector REST endpoints
use OAuth2 and Bearer Tokens to accomplish this. Once a valid token is received from the server, it can
be used in subsequent requests inside an authentication header.
is done by means of optional query parameters. While the query parameters supported will be
controller action dependent some conventions have been established.
• 200 OK – Response to a successful request GET, PUT, or DELETE. May be used for a POST which
doesn’t create a resource.
• 201 Created – Response to a successful POST which creates a resource.
• 204 No Content – Response to a successful DELETE which removes a resource.
• 400 Bad Request – Response to any request which is malformed.
• 401 Unauthorized – Response to any request which does not include a valid Bearer Token.
• 404 Not Found – Response to any request to an undefined resource.
• 429 Too Many Requests – Response to any request which exceeds configured throttling limits.
• 500 Internal Server Error – Response to a request which results in an error generated on the Server.
• X-Total-Count – Includes the actual number of filtered resources available for a given request when
the entire set of resources is not returned.
• Link Headers – Link headers provide fully formed URLs to other pages of data. Link headers for the
“First”, “Next”, and “Previous” page of resources are added when appropriate.
White Lists of IP address can be added to exempt throttling and overrides in the form of key based
and/or IP based rates can also be added.
5.1.1 MongooseEwsRestProvider
Serves data sourced from a native SmartConnector EWS Server.
5.1.2 SoapEwsRestProvider
Serves data sourced from any EWS Server using the standard EWS SOAP protocol. Any server which
supports either the EWS v1.1 or EWS v1.2 specification can be used.
5.1.3 SboEwsRestProvider
Serves data for any SmartStruxure Building Operation (SBO) server using a combination of SOAP and
native protocol commands.
There number and type of REST endpoints you wish to provision in SmartConnector is only limited by
the available resources on the host computer. Regardless of the type, the process is the same however
some configuration parameters will differ depending on the type of Data Provider used.
SmartConnector will not immediately start the REST Endpoint because the configuration is not yet
complete. If you click the “Validate” button, you will see what SmartConnector detects as issues. The
actual issues will depend on which Data Provider you chose in step 6 above.
When you click the “Details” tab, SmartConnector will display the details for the Data Provider you
selected as shown in Figure 1.
• Scheme – The scheme, HTTP or HTTPS, of the endpoint. See Security Considerations when
deploying to a production environment.
• Host – The endpoint which is configured. This can be either an IP address or DNS name as desired.
• Port – The HTTP port used.
• Base Route – An optional base or prefix route which occurs before the standard routes.
Expanding the “Http Configuration” node, will display more options as shown in Figure 2.
• Access Token Expire Time Span Minutes – The amount of time the authorization Bearer Token is
usable.
• Token Endpoint Path – The name of the route which is used to acquire the Bearer token.
• Serve Swagger Metadata – Whether or not Swagger and Swagger metadata are served.
• Name – How the Name of the endpoint will appear to Swagger users.
• Cache Tenant Id – Id of a SmartConnector InMemoryCache Tenant space allocated to the Data
Provider.
Throttling Policy
Further expanding the “Throttling Policy” node, will display options for controlling call rates as shown in
Figure 3.
Document : Revision Revision date Page
TDS-M- EWSRESTGATEWAY-US.BU.N.EN.12.2017.02.30.CC 2 8/16/2018 Page 11 of 76
SmartConnector RESTful EWS Gateway
Default Rates
The “Default Rates” establish a base line for throttling. Typically, the values set here are the most
restrictive but that is only a recommendation. Values work cooperatively where a “Per Second” limit
and “Per Day” limit work in tandem. For example, calls may be limited to 2 per second but no more
than 100 per day. An empty or “0” value indicates that no restriction is to be made.
Optional IP addresses, or range of addresses, can be added which would eliminate (white list) all calls
made. This should only be used for trusted clients.
Client Overrides
Overrides to the base rates can be created based on an API Key. A unique key is assigned to a class of
clients. These clients would then include the “key” in an “Authorization-Token” header in order to be
governed by the updated rates.
• Api Key – Unique API key which will override the default rates with those set here.
• Per Second – The number of requests allowed per second.
• Per Minute – The number of requests allowed per minute.
• Per Hour – The number of requests allowed per hour.
• Per Day – The number of requests allowed per day.
• Per Week – The number of requests allowed per week.
Ip Overrides
• Ip Address – Ip address (or range) which will override the default rates with those set here.
• Per Second – The number of requests allowed per second.
• Per Minute – The number of requests allowed per minute.
• Per Hour – The number of requests allowed per hour.
• Per Day – The number of requests allowed per day.
• Per Week – The number of requests allowed per week.
• Ews Server Id – The ID of the SmartConnector EWS Server which will be the data source. This value
is displayed on the EWS Server Detail page. See SmartConnector Installation and Configuration
Guide for more information.
• Server Address – The full SOAP endpoint for the EWS server which will be the data source.
• Server Domain – The domain for the user credentials which will be used to connect to SBO.
• Server Address – The HTTP endpoint for the SBO server which will be used to serve data. This only
needs to be the IP address (or DNS name) and port.
• Search In Subservers – Whether or not GET requests for lists objects will search in both the top level
(e.g. and ES) server and children (e.g. ASes) or just the top level server.
The following sections enumerate the resources and actions which comprise the RESTful EWS Gateway
API. Each action additionally lists applicable parameters and their type. Data Provider restrictions are
noted when appropriate.
5.3.1 AlarmEvents
An AlarmEvent represents the transition of an Alarm through the state transition model implemented.
Every transition for an Alarm, including a return to normal, generates an AlarmEvent instance.
Disabled=4
See section 4.4.1 from the EWS Specification for more details.
Description Parameter
Parameter Data Type
Type
alarmId Return only AlarmEvent for the Query String
referenced Alarm.
priorityFrom Return only AlarmEvent with a Query Integer
Priority greater or equal to the value
supplied.
priorityTo Return only AlarmEvent with a Query Integer
Priority less or equal to the value
supplied.
state Return only AlarmEvent with this Query Enumeration
State value. (See Table 1)
acknowledgeable Return only AlarmEvent with this Query Enumeration
Acknowledgeable value. (See Table 1)
type Return only AlarmEvent with this Query String
Type value.
originallyAlarmedOnOrAfter Return only AlarmEvent with Query DateTime
OccuredOn which is on or after this
value.
originallyAlarmedBefore Return only AlarmEvent with Query DateTime
OccuredOn which is before this
value.
transitionedOnOrAfter Return only AlarmEvent with Query DateTime
LastTransitionedOn which is on or
after this value.
transitionedBefore Return only AlarmEvent with Query DateTime
LastTransitionedOn which is before
this value.
orderBy AlarmEvent will be returned in this Query Enumeration
order. TransitionedAtAscending by TransitionedAtAscending=0
default. TransitionedAtDescending=1
OriginallyAlarmedAtAscending=2
OriginallyAlarmedAtDescending=3
Description Parameter
Parameter Data Type
Type
id Id of the AlarmEvent requested. Path String
Must be double URL encoded.
Table 3: GET /AlarmEvents/{id} Parameters
Description Parameter
Parameter Data Type
Type
id Id of the AlarmEvent whose AlarmId Path String
property is to be returned. Must be
double URL encoded.
Table 4: GET /AlarmEvents/{id}/AlarmId Parameters
Description Parameter
Parameter Data Type
Type
id Id of the AlarmEvent for which the Path String
referenced Alarm is to be returned.
Must be double URL encoded.
Table 5: GET /AlarmEvents/{id}/Alarm Parameters
Description Parameter
Parameter Data Type
Type
id Id of the AlarmEvent whose Path String
Acknowledgeable property is to be
returned. Must be double URL
encoded.
Description Parameter
Parameter Data Type
Type
Id Id of the AlarmEvent whose Path String
OccurredOn property is to be
returned. Must be double URL
encoded.
Table 7: GET /AlarmEvents/{id}/OccurredOn Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the AlarmEvent whose Path String
LastTransitionedOn property is to be
returned. Must be double URL
encoded.
Table 8: GET /AlarmEvents/{id}/LastTransitionedOn Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the AlarmEvent whose Message Path String
property is to be returned. Must be
double URL encoded.
Table 9: GET /AlarmEvents/{id}/Message Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the AlarmEvent whose Priority Path String
property is to be returned. Must be
double URL encoded.
Table 10: GET /AlarmEvents/{id}/Priority Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the AlarmEvent whose State Path String
property is to be returned. Must be
double URL encoded.
Table 11: GET /AlarmEvents/{id}/State Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the AlarmEvent whose Type Path String
property is to be returned. Must be
double URL encoded.
Table 12: GET /AlarmEvents/{id}/Type Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the AlarmEvent to Path String
Acknowledge. Must be double URL
encoded.
Table 13: GET /AlarmEvents/{id}/Acknowledge Parameters
5.3.2 AlarmEventTypes
An AlarmEventType represents a server specific a Type for an AlarmEvent.
Description Parameter
Parameter Data Type
Type
Description Parameter
Parameter Data Type
Type
name Return only AlarmEventType whose Query String
Name contains this value.
orderBy AlarmEventType will be returned in Query Enumeration
this order. NameAscending by NameAscending=0
default. NameDescending=1
take Number of AlarmEventType that Query Integer
should be returned. 200 by default.
skip Number of AlarmEventType that Query Integer
should be skipped before items are
returned. 0 by default.
Table 16: GET /AlarmEventTypes Parameters
Description Parameter
Parameter Data Type
Type
id Id of the AlarmEventType requested. Path String
Must be double URL encoded.
Table 17: GET /AlarmEventTypes/{id} Parameters
Description Parameter
Parameter Data Type
Type
id Id of the AlarmEventType whose Path String
Description property is to be
Description Parameter
Parameter Data Type
Type
id Id of the AlarmEventType whose Path String
Description property is to be
modified. Must be double URL
encoded.
newValue New Description value. Body String
Table 19: PUT /AlarmEventTypes/{id}/Description Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the AlarmEventType whose Path String
Name property is to be returned.
Must be double URL encoded.
Table 20: GET /AlarmEventTypes/{id}/Name Parameters
Description Parameter
Parameter Data Type
Type
id Id of the AlarmEventType whose Path String
Name property is to be modified.
Must be double URL encoded.
newValue New Name value. Body String
Table 21: PUT /AlarmEventTypes/{id}/Name Parameters
Description Parameter
Parameter Data Type
Type
id Id of the AlarmEventType to be Path String
modified. Must be double URL
encoded.
newValue Values to update the Body Object
AlarmEventType with.
Description New Description value. String
Name New Name value. String
Table 22: PATCH /AlarmEventTypes/{id}/Update Parameters
Description Parameter
Parameter Data Type
Type
id Id of the AlarmEventType to be Path String
deleted. Must be double URL
encoded.
Table 23: DELETE /AlarmEventTypes/{id}/Delete Parameters
5.3.3 Alarms
The existence of an Alarm does not imply that an alarm has occurred, only that alarm criteria exists.
Typically, this is done for a specific Value but this is not required. If Alarm is associated with a Value, the
Id of that Value should be included.
Description Parameter
Parameter Data Type
Type
newItem Definition of how the Alarm will be Body Object
created.
Description Description for the new Alarm. String
Description Parameter
Parameter Data Type
Type
name Return only Alarm whose name Query String
contains this value.
state Return only Alarm with this State Query Enumeration
value. See Table 24
orderBy Alarm will be returned in this order. Query Enumeration
NameAscending by default. NameAscending=0
NameDescending=1
take Number of Alarm that should be Query Integer
returned. 200 by default.
skip Number of Alarm that should be Query Integer
skipped before items are returned.
0 by default.
Table 26: GET /Alarms Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Alarm requested. Must be Path String
double URL encoded.
Table 27: GET /Alarms/{id} Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Alarm whose Description Path String
property is to be returned. Must be
double URL encoded.
Table 28: GET /Alarms/{id}/Description Parameters
Description Parameter
Parameter Data Type
Type
Description Parameter
Parameter Data Type
Type
Id Id of the Alarm whose Name Path String
property is to be returned. Must be
double URL encoded.
Table 30: GET /Alarms/{id}/Name Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Alarm whose Name Path String
property is to be modified. Must be
double URL encoded.
newValue New Name value. Body String
Table 31: PUT /Alarms/{id}/Name Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Alarm whose parent Path String
Container is to be returned. Must
be double URL encoded.
Table 32: GET /Alarms/{id}/Parent Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the Alarm whose ParentId Path String
property is to be returned. Must be
double URL encoded.
Table 33: GET /Alarms/{id}/ParentId Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Alarm whose ParentId Path String
property is to be modified. Must be
double URL encoded.
newValue New ParentId value. Body String
Table 34: PUT /Alarms/{id}/ParentId Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the Alarm whose State Path String
property is to be returned. Must be
double URL encoded.
Table 35: GET /Alarms/{id}/State Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the Alarm whose Path String
TransitionModel property is to be
returned. Must be double URL
encoded.
Table 36: GET /Alarms/{id}/TransitionModel Parameters
SoapEwsRestProvider does support this action however, the value returned will always be Unrestricted
because the EWS SOAP protocol does not directly support this property even though it discusses the
topic of state transition at length.
Document : Revision Revision date Page
TDS-M- EWSRESTGATEWAY-US.BU.N.EN.12.2017.02.30.CC 2 8/16/2018 Page 25 of 76
SmartConnector RESTful EWS Gateway
Description Parameter
Parameter Data Type
Type
id Id of the Alarm whose associated Path String
Value is to be returned. Must be
double URL encoded.
Table 37: GET /Alarms/{id}/Value Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the Alarm whose ValueId Path String
property is to be returned. Must be
double URL encoded.
Table 38: GET /Alarms/{id}/ValueId Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Alarm to be modified. Path String
Must be double URL encoded.
updatedItem Values to update the Alarm with. Body Object
Description New Description value. String
Name New Name value. String
ParentId New ParentId value. String
Table 39: PATCH /Alarm/{id}/Update Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Alarm whose Id property is Path String
to be modified. Must be double
URL encoded.
newValue New Id value. Body String
Table 40: PUT /Alarms/{id}/Id Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Alarm to be acknowledged. Path String
Must be double URL encoded.
newEvent Information to describe the Body Object
generated AlarmEvent.
Message Message for the generated String
AlarmEvent.
Priority Priority for the generated Integer
AlarmEvent.
Type Server specific type for the String
generated AlarmEvent.
Table 41: POST /Alarm/{id}/Acknowledge Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Alarm to be activated. Path String
Must be double URL encoded.
newEvent Information to describe the Body Object
generated AlarmEvent.
Message Message for the generated String
AlarmEvent.
Priority Priority for the generated Integer
AlarmEvent.
Description Parameter
Parameter Data Type
Type
id Id of the Alarm to be disabled. Must Path String
be double URL encoded.
newEvent Information to describe the Body Object
generated AlarmEvent.
Message Message for the generated String
AlarmEvent.
Priority Priority for the generated Integer
AlarmEvent.
Type Server specific type for the String
generated AlarmEvent.
Table 43: POST /Alarm/{id}/Disable Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Alarm to be reset. Must be Path String
double URL encoded.
newEvent Information to describe the Body Object
generated AlarmEvent.
Message Message for the generated String
AlarmEvent.
Priority Priority for the generated Integer
AlarmEvent.
Description Parameter
Parameter Data Type
Type
id Id of the Alarm to be reset. Must be Path String
double URL encoded.
newEvent Information to describe the Body Object
generated AlarmEvent.
Message Message for the generated String
AlarmEvent.
Priority Priority for the generated Integer
AlarmEvent.
Type Server specific type for the String
generated AlarmEvent.
Table 45: POST /Alarm/{id}/ChangeState Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Alarm to be deleted. Must Path String
be double URL encoded.
Table 46: DELETE /Alarms/{id}/Delete Parameters
5.3.4 Containers
A Container is the parent for other types; namely Value, Alarm, Container, and Trend.
Description Parameter
Parameter Data Type
Type
newItem Definition of how the Container will be Body Object
created.
Description Description for the new Container. String
Description Parameter
Parameter Data Type
Type
name Return only Container whose Name Query String
contains this value.
type Return only Container with this Type Query Enumeration
value. See Table 47
Description Parameter
Parameter Data Type
Type
id Id of the Container requested. Must Path String
be double URL encoded.
Table 50: GET /Containers/{id} Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Container whose children Path String
are to be returned. Must be double
URL encoded.
type Return only those children which Query Enumeration
are of this type. All returned by Container=0
default. Value=1
Trend=2
Alarm=3
Table 51: GET /Containers/{id}/Children Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Container whose Path String
Description property is to be
returned. Must be double URL
encoded.
Table 52: GET /Containers/{id}/Description Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Container whose Path String
Description property is to be
modified. Must be double URL
encoded.
newValue New Description value. Body String
Table 53: PUT /Containers/{id}/Description Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Container whose Name Path String
property is to be returned. Must be
double URL encoded.
Table 54: GET /Containers/{id}/Name Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Container whose Name Path String
property is to be modified. Must be
double URL encoded.
newValue New Name value. Body String
Table 55: PUT /Containers/{id}/Name Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Container whose parent Path String
Container is to be returned. Must
be double URL encoded.
Table 56: GET /Containers/{id}/Parent Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Container whose ParentId Path String
property is to be returned. Must be
double URL encoded.
Table 57: GET /Containers/{id}/ParentId Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Container whose ParentId Path String
property is to be modified. Must be
double URL encoded.
newValue New ParentId value. Body String
Table 58: PUT /Containers/{id}/ParentId Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Container whose Type Path String
property is to be returned. Must be
double URL encoded.
Table 59: GET /Containers/{id}/Type Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Container whose Type Path String
property is to be modified. Must be
double URL encoded.
newValue New Type value. Body Enumeration
See Table 47
Table 60: PUT /Containers/{id}/Type Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Container to be modified. Path String
Must be double URL encoded.
updatedItem Values to update the Container Body Object
with.
Description New Description value. String
Id New Id value. String
Name New Name value. String
ParentId New ParentId value. String
Type New Type value. Enumeration
See Table 47.
Table 61: PATCH /Containers/{id}/Update Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Container whose Id Path String
property is to be modified. Must be
double URL encoded.
Document : Revision Revision date Page
TDS-M- EWSRESTGATEWAY-US.BU.N.EN.12.2017.02.30.CC 2 8/16/2018 Page 34 of 76
SmartConnector RESTful EWS Gateway
Description Parameter
Parameter Data Type
Type
id Id of the Container to be deleted. Path String
Must be double URL encoded.
Table 63: DELETE /Containers/{id}/Delete Parameters
5.3.5 Notifications
A Notification represents a logical session of NotificationItem for a Subscription at a point in time.
Description Parameter
Parameter Data Type
Type
newItem Definition of how the Notification will Body Object
be created.
SubscriptionId Id of the Subscription the String
Notification will be created under.
ChangesOnly If true, all items will be returned. If Boolean
false, only changes since the last
Notification for the Subscription will
be created.
Table 65: POST /Notifications/Create Parameters
Description Parameter
Parameter Data Type
Type
subscriptionId Return only Notification with this Query String
SubscriptionId value.
orderBy Notification will be returned in this Query Enumeration
order. CreatedOnAscending by CreatedOnAscending=0
default. CreatedOnDescending=1
take Number of Notification that should Query Integer
be returned. 200 by default.
skip Number of Notification that should Query Integer
be skipped before items are
returned. 0 by default.
Table 66: GET /Notifications Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Notification requested. Path String
Must be double URL encoded.
Table 67: GET /Notifications/{id} Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the Notification whose Path String
CreatedOn property is to be
returned. Must be double URL
encoded.
Table 68: GET /Notifications/{id}/CreatedOn Parameters
A NotificationItem represents a single event notification for given Notification session belonging to a
given Subscription. The properties of a NotificationItem are listed in Table 69.
Description Parameter
Parameter Data Type
Type
id Id of the Notification whose items Path String
are to be returned. Must be double
URL encoded.
take Number of NotificationItems that Query Integer
Description Parameter
Parameter Data Type
Type
id Id of the Notification whose Path String
Subscription is to be returned. Must
be double URL encoded.
Table 71: GET /Notifications/{id}/Subscription Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Notification whose Path String
SubscriptionId property is to be
returned. Must be double URL
encoded.
Table 72: GET /Notifications/{id}/SubscriptionId Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Notification to be deleted. Path String
Must be double URL encoded.
Table 73: DELETE /Notifications/{id}/Delete Parameters
5.3.6 Root
Since it is not always feasible to know the Id of the “root” Container, a special resource named “Root”
provides that Container.
5.3.6.1 GET /
Returns the root Container which all other data is rooted.
5.3.7 Subscriptions
A Subscription is as data registration to one or more items for the purpose of creating Notification
sessions to retrieve NotificationItem when the subscribed items have changed.
Description Parameter
Parameter Data Type
Type
newItem Definition of how the Subscription will Body Object
be created.
DurationInMinutes The requested duration for the Integer
Subscription.
SubscriptionType The type of data to subscribe to. Enumeration
See Table 74
Ids List of Ids of items which are being String[]
Subscribed to.
PriorityFrom For AlarmEventChanged and Integer
SystemEventChanged subscriptions,
only items with Priority at or above
this value will be included.
PriorityTo For AlarmEventChanged and Integer
SystemEventChanged subscriptions,
only items with Priority below this
value will be included.
Types For AlarmEventChanged and String[]
SystemEventChanged subscriptions,
only items with a Type in this List
will be included.
Description Parameter
Parameter Data Type
Type
type Return only Subscription with this Query Enumeration
Type value. See Table 74
orderBy Subscription will be returned in this Query Enumeration
order. ExpiresAscending by default. ExpiresAscending=0
ExpiresDescending=1
take Number of Subscription that should Query Integer
be returned. 200 by default.
skip Number of Subscription that should Query Integer
be skipped before items are
returned. 0 by default.
Table 76: GET /Subscriptions Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Subscription requested. Path String
Must be double URL encoded.
Table 77: GET /Subscriptions/{id} Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the Subscription whose ExpiresOn Path String
property is to be returned. Must be
double URL encoded.
Table 78: GET /Subscriptions/{id}/ExpiresOn Parameters
Description Parameter
Parameter Data Type
Type
Description Parameter
Parameter Data Type
Type
id Id of the Subscription whose IsActive Path String
property is to be returned. Must be
double URL encoded.
Table 80: GET /Subscriptions/{id}/IsActive Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Subscription to be Path String
renewed. Must be double URL
encoded.
Minutes Value in minutes to extend the Body Integer
Subscription.
Table 81: PUT /Subscriptions/{id}/Renew Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Subscription to be Path String
terminated. Must be double URL
encoded.
Table 82: PUT /Subscriptions/{id}/Terminate Parameters
Description Parameter
Parameter Data Type
Type
Document : Revision Revision date Page
TDS-M- EWSRESTGATEWAY-US.BU.N.EN.12.2017.02.30.CC 2 8/16/2018 Page 41 of 76
SmartConnector RESTful EWS Gateway
Description Parameter
Parameter Data Type
Type
id Id of the Subscription which Path String
Notification are to be deleted. Must
be double URL encoded.
Table 84: DELETE /Subscriptions/{id}/DeleteNotifications Parameters
5.3.8 SystemEvents
A SystemEvent represents the occurrence of a server specific event.
Description Parameter
Parameter Data Type
Type
priorityFrom Return only SystemEvent with a Query Integer
Priority greater or equal to the value
supplied.
priorityTo Return only SystemEvent with a Query Integer
Priority less or equal to the value
supplied.
state Return only SystemEvent with this Query Enumeration
State value. (See Table 1)
acknowledgeable Return only SystemEvent with this Query Enumeration
Acknowledgeable value. (See Table 1)
type Return only SystemEvent with this Query String
Type value.
occurredOnOrAfter Return only SystemEvent with Query DateTime
OccurredOn which is on or after this
value.
occurredBefore Return only SystemEvent with Query DateTime
OccurredOn which is before this
value.
orderBy SystemEvent will be returned in this Query Enumeration
order. OccurredOnAscending by OccurredOnAscending =0
default. OccurredOnDescending =1
take Number of SystemEvent that should Query Integer
be returned. 200 by default.
skip Number of SystemEvent that should Query Integer
be skipped before items are
returned. 0 by default.
Table 86: GET /SystemEvents Parameters
Description Parameter
Parameter Data Type
Type
id Id of the SystemEvent requested. Path String
Must be double URL encoded.
Table 87: GET /SystemEvents/{id} Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the SystemEvent whose Message Path String
property is to be returned. Must be
Description Parameter
Parameter Data Type
Type
Id Id of the SystemEvent whose Path String
OccurredOn property is to be
returned. Must be double URL
encoded.
Table 89: GET /SystemEvents/{id}/OccurredOn Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the SystemEvent whose Priority Path String
property is to be returned. Must be
double URL encoded.
Table 90: GET /SystemEvents/{id}/Priority Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the SystemEvent whose SourceId Path String
property is to be returned. Must be
double URL encoded.
Table 91: GET /SystemEvents/{id}/Priority Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the SystemEvent whose Path String
SourceName property is to be
returned. Must be double URL
encoded.
Table 92: GET /SystemEvents/{id}/Priority Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the SystemEvent whose Type Path String
property is to be returned. Must be
double URL encoded.
Table 93: GET /SystemEvents/{id}/Type Parameters
5.3.9 SystemEventTypes
A SystemEventType represents a server specific a Type for a SystemEvent.
Description Parameter
Parameter Data Type
Type
name Return only SystemEventType whose Query String
Name contains this value.
orderBy SystemEventType will be returned in Query Enumeration
this order. NameAscending by NameAscending=0
default. NameDescending=1
Description Parameter
Parameter Data Type
Type
id Id of the SystemEventType requested. Path String
Must be double URL encoded.
Table 96: GET /SystemEventTypes/{id} Parameters
Description Parameter
Parameter Data Type
Type
id Id of the SystemEventType whose Path String
Description property is to be
returned. Must be double URL
encoded.
Table 97: GET /SystemEventTypes/{id}/Description Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the SystemEventType whose Path String
Name property is to be returned.
Must be double URL encoded.
Table 98: GET /SystemEventTypes/{id}/Name Parameters
5.3.10 Trends
A Trend references a specific Value for which historical value "trending" has been enabled. The
existence of a Trend does not imply that history exists; only that history will be captured for a Value.
Description Parameter
Parameter Data Type
Type
newItem Definition of how the Trend will be Body Object
created.
Description Description for the new Trend. String
Id Id for the new Trend. String
Name Name for the new Trend. String
ParentId Optional Id of the Container the String
new Trend will be put into.
Type Type for the new Trend. Enumeration
See Table 99
ValueId Id for the Value for which historical String
trends will be captured.
Table 100: POST /Containers/Create Parameters
Description Parameter
Parameter Data Type
Type
name Return only Trend whose name Query String
contains this value.
orderBy Trend will be returned in this order. Query Enumeration
NameAscending by default. NameAscending=0
NameDescending=1
take Number of Trend that should be Query Integer
returned. 200 by default.
skip Number of Trend that should be Query Integer
skipped before items are returned.
0 by default.
Table 101: GET /Trends Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Trend requested. Must be Path String
double URL encoded.
Table 102: GET /Trends/{id} Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Trend whose Description Path String
property is to be returned. Must be
double URL encoded.
Table 103: GET /Trends/{id}/Description Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Trend whose Description Path String
property is to be modified. Must be
double URL encoded.
newValue New Description value. Body String
Table 104: PUT /Trends/{id}/Description Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Trend whose Name Path String
property is to be returned. Must be
double URL encoded.
Table 105: GET /Trends/{id}/Name Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Trend whose Name Path String
property is to be modified. Must be
double URL encoded.
newValue New Name value. Body String
Table 106: PUT /Trends/{id}/Name Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Trend whose parent Path String
Container is to be returned. Must
be double URL encoded.
Description Parameter
Parameter Data Type
Type
id Id of the Trend whose ParentId Path String
property is to be returned. Must be
double URL encoded.
Table 108: GET /Trends/{id}/ParentId Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Trend whose ParentId Path String
property is to be modified. Must be
double URL encoded.
newValue New ParentId value. Body String
Table 109: PUT /Trends/{id}/ParentId Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Trend whose Type property Path String
is to be returned. Must be double
URL encoded.
Table 110: GET /Trends/{id}/Type Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Trend whose Unit property Path String
is to be returned. Must be double
URL encoded.
Table 111: GET /Trends/{id}/Unit Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Trend whose Value is to be Path String
returned. Must be double URL
encoded.
Table 112: GET /Trends/{id}/Value Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Trend whose ValueId Path String
property is to be returned. Must be
double URL encoded.
Table 113: GET /Trends/{id}/ValueId Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Trend to be modified. Path String
Must be double URL encoded.
updatedItem Values to update the Trend with. Body Object
Description New Description value. String
Id New Id value. String
Name New Name value. String
ParentId New ParentId value. String
Table 114: PATCH /Trends/{id}/Update Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Trend whose Id property is Path String
Description Parameter
Parameter Data Type
Type
id Id of the Trend to be deleted. Must Path String
be double URL encoded.
Table 116: DELETE /Containers/{id}/Delete Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Trend for which Path String
TrendSample are to be deleted.
Must be double URL encoded.
sampleDateRange Only TrendSample with a Body Object
SampleDate in this range will be
deleted.
Before DateTime in UTC DateTime
OnOrAfter DateTime in UTC DateTime
Table 117: DELETE /Trends/{id}/DeleteTrendSamples Parameters
5.3.11 TrendSamples
A TrendSample represents the value and state for Value at a given point in time belonging to a specific
Trend.
sample. Good=0
Uncertain=1
Forced=2
Offline=3
Error=4
See section 4.3.4 of the EWS Specification for more details.
Description Parameter
Parameter Data Type
Type
alarmId Return only AlarmEvent for the Query String
referenced Alarm.
trendId The Id of the Trend which Query String
TrendSample are to be returned for.
This parameter is not optional.
state Return only TrendSample with this Query Enumeration
State value. (See Table 1)
sampleOnOrAfter Return only TrendSample with Query DateTime
SampleDate which is on or after this
value.
sampledBefore Return only TrendSample with Query DateTime
SampleDate which is before this
value.
orderBy TrendSample will be returned in this Query Enumeration
order. SampleDateAscending by SampleDateAscending=0
default. SampleDateDescending=1
take Number of TrendSample that should Query Integer
be returned. 200 by default.
skip Number of TrendSample that should Query Integer
be skipped before items are
returned. 0 by default.
Table 119: GET /TrendSamples Parameters
Description Parameter
Parameter Data Type
Type
id Id of the TrendSample requested. Path String
Must be double URL encoded.
Table 120: GET /TrendSamples/{id} Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the TrendSample whose State Path String
property is to be returned. Must be
double URL encoded.
Table 121: GET /AlarmEvents/{id}/State Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the TrendSample whose Path String
SampleDate property is to be
returned. Must be double URL
encoded.
Table 122: GET /TrendSamples/{id}/SampleDate Parameters
Description Parameter
Parameter Data Type
Type
Id Id of the TrendSample whose Trend is Path String
to be returned. Must be double
URL encoded.
Table 123: GET /TrendSamples/{id}/Trend Parameters
Description Parameter
Parameter Data Type
Type
Description Parameter
Parameter Data Type
Type
Id Id of the TrendSample whose Value is Path String
to be returned. Must be double
URL encoded.
Table 125: GET /TrendSamples/{id}/Value Parameters
5.3.12 Values
A Value represents a singular point value. Point values can be physical values from a sensor or
controller, internal properties such as a software version, or any other value an implementing server
decides to expose.
Integer=5
Duration=6
See Section 4.3.2 from the EWS Specification for more details.
Description Parameter
Parameter Data Type
Type
newItem Definition of how the Value will be Body Object
created.
Description Description for the new Value. String
Forceable Forceable for the new Value. Enumeration
Id Id for the new Value. String
Name Name for the new Value. String
ParentId Optional Id of the Value the new String
Value will be put into.
State State for the new Value. Enumeration
Type Type for the new Value. Enumeration
See Table 47
Unit Unit for the new Value String
Value Value for the new Value String
Writeable Writeable for the new Value. Enumeration
Table 127: POST /Values/Create Parameters
Description Parameter
Parameter Data Type
Type
name Return only Value whose name Query String
Description Parameter
Parameter Data Type
Type
id Id of the Value requested. Must be Path String
double URL encoded.
Table 129: GET /Values/{id} Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Value whose Description Path String
property is to be returned. Must be
double URL encoded.
Table 130: GET /Values/{id}/Description Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Value whose Description Path String
property is to be modified. Must be
double URL encoded.
Description Parameter
Parameter Data Type
Type
id Id of the Value whose Forceable Path String
property is to be returned. Must be
double URL encoded.
Table 132: GET /Values/{id}/Forceable Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Value whose Forceable Path String
property is to be modified. Must be
double URL encoded.
newValue New Forceable value. Body String
Table 133: PUT /Values/{id}/Forceable Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Value whose Name Path String
property is to be returned. Must be
double URL encoded.
Table 134: GET /Values/{id}/Name Parameters
Description Parameter
Parameter Data Type
Type
Description Parameter
Parameter Data Type
Type
id Id of the Value whose parent Path String
Container is to be returned. Must
be double URL encoded.
Table 136: GET /Values/{id}/Parent Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Value whose ParentId Path String
property is to be returned. Must be
double URL encoded.
Table 137: GET /Values/{id}/ParentId Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Value whose ParentId Path String
property is to be returned. Must be
double URL encoded.
Table 138: PUT /Values/{id}/ParentId Parameters
Description Parameter
Parameter Data Type
Type
id Id of the State whose Type property Path String
is to be returned. Must be double
URL encoded.
Table 139: GET /Values/{id}/State Parameters
Description Parameter
Parameter Data Type
Type
id Id of the State whose Type property Path String
is to be modified. Must be double
URL encoded.
newValue New State value. Body Enumeration
See Table 47
Table 140: PUT /Values/{id}/State Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Value whose Type property Path String
is to be returned. Must be double
URL encoded.
Table 141: GET /Values/{id}/Type Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Value whose Type property Path String
is to be modified. Must be double
URL encoded.
newValue New Type value. Body Enumeration
See Table 47
Table 142: PUT /Values/{id}/Type Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Value whose Unit property Path String
is to be returned. Must be double
URL encoded.
Table 143: GET /Values/{id}/Unit Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Value whose Unit property Path String
is to be modified. Must be double
URL encoded.
newValue New Unit value. Body Enumeration
See Table 47
Table 144: PUT /Values/{id}/Unit Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Value whose Value property Path String
is to be returned. Must be double
URL encoded.
Table 145: GET /Values/{id}/Value Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Value whose Value Path String
property is to be modified. Must be
Document : Revision Revision date Page
TDS-M- EWSRESTGATEWAY-US.BU.N.EN.12.2017.02.30.CC 2 8/16/2018 Page 61 of 76
SmartConnector RESTful EWS Gateway
Description Parameter
Parameter Data Type
Type
id Id of the Value whose Writeable Path String
property is to be returned. Must be
double URL encoded.
Table 147: GET /Values/{id}/Writeable Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Value whose Writeable Path String
property is to be modified. Must be
double URL encoded.
newValue New Writeable value. Body String
Table 148: PUT /Values/{id}/Writeable Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Value to be modified. Path String
Must be double URL encoded.
updatedItem Values to update the Value with. Body Object
Description New Description value. String
Forceable New Forceable value. Enumeration
See Table 126
Id New Id value. String
Name New Name value. String
Description Parameter
Parameter Data Type
Type
id Id of the Value whose Id property is Path String
to be modified. Must be double
URL encoded.
newValue New Id value. Body String
Table 150: PUT /Values/{id}/Id Parameters
Description Parameter
Parameter Data Type
Type
id Id of the Value to be forced. Must Path String
be double URL encoded.
forcedValue Value which the Value will be forced Body String
to.
Table 151: PUT /Values/{id}/Force Parameters
Description Parameter
Parameter Data Type
Type
Description Parameter
Parameter Data Type
Type
id Id of the Value to be deleted. Must Path String
be double URL encoded.
Table 153: DELETE /Values/{id}/Delete Parameters
6 Swagger
The architecture for the SmartConnector REST Extensions integrates Swagger to provide a rich self-
documenting API. What is Swagger? From the Swagger website itself:
“The goal of Swagger™ is to define a standard, language-agnostic interface to REST APIs which allows
both humans and computers to discover and understand the capabilities of the service without access to
source code, documentation, or through network traffic inspection. When properly defined via Swagger,
a consumer can understand and interact with the remote service with a minimal amount of
implementation logic. Similar to what interfaces have done for lower-level programming, Swagger
removes the guesswork in calling the service.
Technically speaking - Swagger is a formal specification surrounded by a large ecosystem of tools, which
includes everything from front-end user interfaces, low-level code libraries and commercial API
management solutions.”
Accessing the Swagger page for any SmartConnector REST Endpoint is quite easy. From the
SmartConnector Portal Status page, view all Active Endpoints as shown in Figure 4. If you do not see a
link then edit the configuration as described above and ensure that “Server Swagger Metadata” is set to
“True”.
Clicking the “Documentation” link for any provisioned REST Endpoint will open the Swagger page in a
new browser tab (Figure 5).
6.1.1 Authentication
Before any commands can be attempted, an authentication Bearer Token is required. To facilitate
authentication, the generic Swagger page has been customized for SmartConnector. In the upper right
corner of the page you will find “username” and “password” input fields and a “Login” button. The red
border around the input fields, as shown in Figure 6, indicates that authentication has not occurred and
no Bearer Token is available.
The credentials required depend on which Data Provider is being used. For example, if you are using the
MongooseEwsRestProvider the credentials required are those of any User account in the referenced
Native EWS Server. Alternatively, if you are using the SoapEwsRestProvider the credentials required are
those of the “EWS User” for the referenced server.
When a valid username and password are entered, clicking the “Login” button will request a valid Bearer
Token from the REST Endpoint. Successful authentication will be indicated with green borders around
the input fields as shown in Figure 7. If authentication fails, the Swagger page will inform you with a
dialog warning. Verify your credentials and try again.
After authentication, Swagger will automatically add the current Bearer Token, in an Authentication
Header, for all actions shown on the Swagger page. This will continue for the duration of the Bearer
Token’s life (or a full page refresh is performed). If the Bear Token expires, you simply need to re-
authenticate by clicking the Login button again.
For example, Figure 8 shows the GET /Root resource action for the RESTful EWS Gateway. This action
requests the “root” Container resource.
The top portion displays the expected success status code for the action (Status 200) and “Example
Value” and “Model” synopsis of the data to be returned. Clicking the “Try it out!” button will issue the
command and display the response as seen in Figure 9.
Document : Revision Revision date Page
TDS-M- EWSRESTGATEWAY-US.BU.N.EN.12.2017.02.30.CC 2 8/16/2018 Page 67 of 76
SmartConnector RESTful EWS Gateway
Of note in the response section are the Curl command, Request URL, Response Body and Response
Code, and Response Headers.
• Curl – Shows how the request was made, including all header and parameter information.
Examining the link you will see the “Accept” and “Authorization” header values along with the
URL Swagger requested.
• Request URL – Shows the URL aspect only and is helpful when parameters are added to the
request.
• Response Body – The actual body of the response. In our case, we see the root Container in
JSON format (because we issued the request with an “Accept” header of “application/json”.
• Response Code – The HTTP code of the response.
• Response Headers – Shows all response headers from the server. This will where any custom
response headers will be included when appropriate.
If we change the content type to “application/xml” and click “Try it out!” again, the server will respond
in much the same manner as shown in Figure 10. Note that the Response Body and Response Header
for “content-type” now show XML format. Whether JSON or XML format is used is largely the
preference of the consumer and has no functional difference other than XML payload will be larger due
to the additional markup included.
6.1.3 Parameters
Reviewing the resources and actions supported by the RESTful EWS Gateway, you will notice that there
are three types of parameters which actions can use: Path, Query, and Body.
Due to their nature, path parameters must be “URL encoded” to remove special characters which would
make the URL invalid. While Swagger does automatically URL encode all Path parameter prior to using
it, the architecture employed in SmartConnector requires double URL encoding. This means that even
when using Swagger, you will be required to encode the path parameter once manually. Fortunately,
free tools or websites like http://meyerweb.com/eric/tools/dencoder/ are available to simplify this.
For example, to retrieve a single Container instance by its Id parameter, the route GET /Containers/{id}
would be used. Taking the value returned from GET /Root (Figure 9), URL encoding it, and entering it
into the Swagger input page we should see something like Figure 11.
As expected, the response shown in Figure 12 is identical in content to that shown in Figure 9. This is
because while we have employed two different resource actions, we are still requesting the “root”
Container in both cases. In the former request, we simply didn’t know what Id to use. We did in the
later request.
Like Path Parameters, Query Parameters must be URL encoded prior to use. For our purposes, only a
single URL encoding is required and since Swagger does this for us automatically, no special attention is
required.
For example, to retrieve all children for a Container, the route GET /Containers/{id}/Children would be
used. Using the Id value returned from GET /Root (Figure 9), URL encoding it, and entering it into the
Swagger page we can request all children. If we only are interested in children that are also of type
Container, we select a “type” value. Clicking “Try it now!” we see the result shown in Figure 13.
Note the “type=Container” (the numeric or enumeration can be used interchangeably) in the Request
URL after the “Children” action. This is how Query Parameters are added to the URL. The first query
parameter is preceded by a “?” character while each subsequent query parameter will be preceded with
an “&” character.
Since Body Parameters are not part of the URL they do not need to be URL encoded. They do however
need to be property formatted depending on the “Parameter content type” option selected.
For example, if we want to add a new Container, we would use the POST /Containers/Create action as
shown in Figure 14.
If we choose “application/json” as the “Parameter content type” then the content of “newItem” must
be valid JSON. Luckily Swagger assists in this regard. If you click anywhere in the “Example Value”,
Swagger will copy the format of the expected content to newItem. As a safeguard, Swagger only does
this when there is no content in the target input field. After that, you can quickly edit the markup and
submit the request as shown in Figure 15.
If XML is your thing, the request would look like Figure 16.
When the action is a PUT or POST on a scalar value, the “application-www-form-urlencoded” option can
also be used. The format used here is slightly different as a preceding “=” character is required.
For example, to change the Type of the Container added above we would use the PUT /Containers/Type
action as shown in Figure 17.
While SmartConnector makes no recommendations on the best language or code generator to use
when consuming SmartConnector REST endpoints, a good place to start is at the Swagger commercial
tools site found here: http://swagger.io/commercial-tools/.
7 Security Considerations
Security Considerations and recommendations are covered in Section 12 of the SmartConnector
Installation and Configuration Guide.