REST Data Source
This data source belongs to the Online category in the data source library. It is used to access, via a connector, the resources of a service (websites or third-party products) in order to retrieve dynamic content.
REST_ServiceResourceAuthentication
- Services offer different types of content and data via resources.
example Twitter ==> Timeline or followers
- Data may be public and accessible to everyone (no user authentication required) or private. In this case, user authentication is required before the resource can be accessed.
example Content read in Google Calendar, Google Contacts, Twitter
Examples
REST_Examples
- No user authentication:
- The http://api.open-notify.org website publishes public data in real-time from the ISS (International Space Station).
==> Thanks to REST architecture, the position of the ISS can be displayed using a Google Maps widget without requiring user authentication.
- Using Basic authentication:
- Creation of a timeline customized by each Twitter user.
==> Thanks to REST architecture and the REST API adopted by Twitter, tweets in a user's timeline can be displayed using a Data Viewer widget with prior user authentication.
- Salesforce enables users to have different views of corporate data, e.g. lists of customers, prospects, projects or sales employees.
==> The REST protocol enables you to display these resources using Data Viewer widgets with prior user authentication.
Notes
See General remarks on data sources.
- To access resources using OAuth 2.0 authentication, use the REST (Connector) data source.
- The type of authentication that can be used depends on the API set up by each service and is described in the API documentation of the service.
- To find out more about the JSON table structure, please consult http://www.json.org.
Caution
- Basic authentication encrypts and stores the login information required by the service in Service Apps.
Best Practice
- If different authentication methods are available for a given service, we recommend that you use OAuth 2.0 authentication whenever possible. In this case, you must use the REST (Connector) data source.
REST_DataSourcesRESTComparizon
How to choose between a REST data source and a REST (Connector) data source
- You should use a REST (Connector) data source to:
- Reuse a service and its resources.
- Access any type of resource for a REST service defined in the app.
- You should use a REST data source to:
- Define and access a REST resource.
- Access resources without user authentication or resources using Basic authentication.
- Use a given resource from a service occasionally (resource not intended for reuse in another app).
List of properties
Content
Authentication Type: User authentication method for accessing the service.
- None: No authentication required because the REST API is open or public.
- Basic: Authentication is performed using Service Apps and communicated to the service via parameters in the URL.
Base URI: The URL for accessing data is made up of the service and the resource proposed by this service.
example
- View the International Space Shuttle (ISS) crew (public data):
- Open APIs From Space service: http://api.open-notify.org/
- People in Space Right Now resource: astros.json
==> Base URI = http://api.open-notify.org/astros.json
- Display JSONPlaceholder comments, a fake REST API with public data used for testing and prototyping:
- JSONPlaceholder service: http://jsonplaceholder.typicode.com/
- comments resource: comments
==> Base URI = http://jsonplaceholder.typicode.com/comments
Basic Authentication Parameters (Note: Only for Basic authentication): Login and password for accessing the resource.
- Click
to modify it.
- To check that you have entered the login information correctly, you can tick the Show my password box.
Selector
Selector: Tool for extracting the data you want from the JSON file of the resource.
- The JSON table contains a list of tags surrounding data subsets using curly brackets, { }.
- You can click the tag you want in the JSON table (2).
The tag will be highlighted in yellow.
or - You can enter an expression in the search field at the top of the window (1) and click Apply
See How to use regular expressions: JSONSelect website
End_Selector
SelectFirstRowAsCurrentRecord
Select First Row As Current Record: Used to indicate if the first record of the data source, when displayed in widgets, is selected by default (box is checked) or not (box is not checked).
NoDataMessage
No Data Message: This message is displayed when the data source does not contain any data.
- Enter the code directly in the field or click
to open the text editor.
AutoRefresh
Auto Refresh (Note: Only for dynamic data sources): Used to indicate the automatic refreshment interval for data from the data source in hours/minutes.
- Data is automatically refreshed each time the app is run and each time the page is redisplayed, regardless of whether it is in execute mode or edit mode.
Master/Detail
SectionMasterDetail
Master Datasource: In a master-detail relationship, this is the name of the master data source linked to the current data source.
Master Field: Name of the primary key in the master data source used to establish the link with the current data source.
- As a general rule, it is the PK (Primary Key) column in the Service Manager) table.
Detail Field: Name of the EasyVista data source column identifying the key in the Service Manager table.
- As a general rule, it is the column whose prefix is FK (Foreign Key).
example You want to display all actions (detail data source) associated with an incident (master data source):
- Master Datasource = Incidents data source defined using the Operation > Incidents > All Incidents parent query.
- Master Field = PK identifying the Incident_ID column in the Incidents table.
- Detail Field = FK_AM_ACTION_REQUEST_ID identifying the action number related to the incident.
Procedure: How to create and use a REST data source
Step 1: Create the REST data source.
1. Click Add Data Source in the Objects pane.
2. Select the data source type, REST (Online category).
Step 2: Define the properties of the new data source.
1. Specify the data source in the Base URI field.
2. Select the authentication method for accessing the resource.
The fields specific to the authentication method will appear.
- (optional) Basic authentication method
- Click
next to Basic Authentication Parameters.
- Specify the login and password.
- Click
3. Select the data of the resource to be displayed.
- Click
next to the Selector field.
- The Selector tool window will appear.
- The contents of the resource will appear in a JSON table.
- You can click the tag you want in the JSON table.
The tag will be highlighted in yellow.
or - You can enter an expression in the search field at the top of the window and click Apply.
- Click OK.
4. Specify the other properties of the data source.
Step 3: Add the widget displaying data from the data source.
1. Click Add Widget in the Objects pane.
2. Select the type of widget you want.
3. Configure it to point to the REST data source you previously configured.
4. Specify the other properties.
Step 4: Test the app.
1. Select the type of device on which you must test the app.
: Display on a PC
: Display on a smartphone
2. Click to run the app.
The app will appear in a new web browser tab.
3. Check that the data from the resource is correctly displayed.
SAS_IntegrationRESTAboutTheUse
About the use of the software companies API REST
- Numerous software companies limit the access to the API REST of their software, generally by basing itself on a number of calls by hour/day/month.
- Only specific editions of their software can be eligible in the use of the API REST (with or without additional cost).
- Some software companies set up plans, e.g., Classic, Professional, Enterprise, for which the number of possible calls to the REST API or even to specific resources (i.e. endpoints) can be more or less numerous.
Examples of integration
Below is a list of the products interfacing with Service Apps using a REST (Connector) data source. See the procedure available in each page.