Creating RESTful Web Services
Create RESTful web services using the Modules, Templates and Handlers pages.
To create a RESTful web service, you need to:
-
Define a resource module
-
Define a resource template
-
Define one or more resource handlers such as GET, PUT, POST or DELETE. Optionally, define parameters that you need to pass to the resource handler.
The following sections provide information on how to create resource modules, resource templates and resource handlers.
- Managing Resource Modules
You can define, edit and delete resource modules in the Modules page. - Managing Resource Templates
You can define, edit and delete resource templates for a module in the Templates page. - Managing Resource Handlers
You can create, edit and delete resource handlers for a template in the Handlers page. - Example: Inserting a Record using a POST Handler
The following example illustrates how to insert a record in the DEPT table.
See Also:
-
Creating a RESTful Service in Oracle REST Data Services Quick Start Guide
Parent topic: The REST Pages
Managing Resource Modules
You can define, edit and delete resource modules in the Modules page.
To navigate to the Modules page, in the REST Overview page, click Modules in Objects, or from the menu in the header, select Modules.
The module attributes displayed by default in card view are shown in the following figure.
The module status can be published or unpublished. If the status is unpublished, the icon is displayed in a red color.
Click the module name in card view to go to the Templates page for that module. You can also navigate to the Templates page through the context menu.
The actions available in the context menu are:
-
Navigating to the Templates page for a module
- Creating a Resource Module
This section describes how to create a resource module. - Importing a Resource Module
- Editing a Resource Module
This section describes how to edit a resource module. - Deleting a Resource Module
This section describes how to delete a resource module. - Publishing/Unpublishing a Resource Module
This section describes how to make a resource module available or not. - Exporting a Resource Module
You can export the PL/SQL source code for the API or Open API (Swagger) JSON code for a resource module or RESTful service. If the module has templates, handlers, parameters, roles, and so on, these objects are also displayed and exported. - Viewing the Module in OpenAPI View
This section describes how to open the module in Open API view.
See Also:
About the REST Search ToolbarParent topic: Creating RESTful Web Services
Creating a Resource Module
This section describes how to create a resource module.
Parent topic: Managing Resource Modules
Importing a Resource Module
Note:
You can import an OpenAPI version 2.0 or 3.0 document in JSON format only.Parent topic: Managing Resource Modules
Editing a Resource Module
This section describes how to edit a resource module.
- In the Modules page, for the specific module, click
and select Edit. - Edit the required fields and click Save. For a description of the fields, see Creating a Resource Module.
Parent topic: Managing Resource Modules
Deleting a Resource Module
This section describes how to delete a resource module.
Parent topic: Managing Resource Modules
Publishing/Unpublishing a Resource Module
This section describes how to make a resource module available or not.
Parent topic: Managing Resource Modules
Exporting a Resource Module
You can export the PL/SQL source code for the API or Open API (Swagger) JSON code for a resource module or RESTful service. If the module has templates, handlers, parameters, roles, and so on, these objects are also displayed and exported.
Parent topic: Managing Resource Modules
Viewing the Module in OpenAPI View
This section describes how to open the module in Open API view.
Parent topic: Managing Resource Modules
Managing Resource Templates
You can define, edit and delete resource templates for a module in the Templates page.
To navigate to this page, in the Modules page, click
for a module and select Templates, or click the name
of the module in card view.
At the top of the page, the module card is available with context menu options such as Edit, Delete, Publish and Export.
The templates attributes displayed by default in card view are shown in the following figure.
Click the template name in card view to go to the Handlers page. You can also navigate to the Handlers page through the context menu.
The actions available in the context menu are:
-
Navigating to the Handlers page for the template
- Creating a Resource Template
This section describes how to create a resource template. - Editing a Resource Template
This section describes how to edit a resource template. - Deleting a Resource Template
This section describes how to delete a resource template.
Parent topic: Creating RESTful Web Services
Creating a Resource Template
This section describes how to create a resource template.
Parent topic: Managing Resource Templates
Editing a Resource Template
This section describes how to edit a resource template.
Parent topic: Managing Resource Templates
Deleting a Resource Template
This section describes how to delete a resource template.
Parent topic: Managing Resource Templates
Managing Resource Handlers
You can create, edit and delete resource handlers for a template in the Handlers page.
To navigate to this page, in the Templates page, click
for a template and select Handlers,
or click the name of the template in card view.
At the top of the page, the template card is available with context menu options such as Edit and Delete.
Tthe handler attributes displayed by default in card view are shown in the following figure.
The HTTP Method can be one of the following: GET, PUT, POST and DELETE.
You can navigate to the HTTP method page using the context menu. There are three tabs displayed in the HTTP method page: Source, Parameters and Pre-Authenticated Requests.
Note:
This option is not available if the template has all four handlers created (GET, POST, PUT, DELETE).The actions available in the context menu are:
-
Edit: See Editing a Resource Handler
-
Delete: See Deleting a Resource Handler
-
Details: See Viewing Resource Handler Details and Managing Parameters
-
Pre-Authenticated Requests: See Pre-authenticated Requests
- Creating a Resource Handler
This section describes how to create a resource handler. - Editing a Resource Handler
This section describes how to edit a resource handler. - Deleting a Resource Handler
This section describes how to delete a resource handler. - Viewing Resource Handler Details and Managing Parameters
You can view resource handler details and manage parameters in the HTTP method page. - Using Pre-Authenticated Requests to Access ORDS RESTful Services
To access protected RESTful services, you can create and revoke pre-authenticated requests.
Parent topic: Creating RESTful Web Services
Editing a Resource Handler
This section describes how to edit a resource handler.
Parent topic: Managing Resource Handlers
Deleting a Resource Handler
This section describes how to delete a resource handler.
Parent topic: Managing Resource Handlers
Viewing Resource Handler Details and Managing Parameters
You can view resource handler details and manage parameters in the HTTP method page.
To navigate to this page, for a specific handler, click
and then select Details or click the
name of the handler in card view.
At the top of the page, the handler card is available with context menu options such as Edit and Delete.
The Handler HTTP method page has two major sections:
-
A code editor for executing the SQL or PL/SQL source code that was defined in the resource handler. You can execute the code, save, undo, redo, download and clear output. For more information about the editor, see Executing SQL Statements in the Code Editor.
Implicit parameters used in REST service handlers are displayed in a scrolling list towards the right side of the editor. See Implicit Parameters
-
A section for managing parameters required for running the HTTP method.
By default, the parameters are displayed in grid view. The attributes displayed on a parameter in card view are shown in the following figure.
The actions available in the context menu are:
- Creating a Parameter
This section describes how to create a parameter for a resource handler. - Editing a Parameter
This section describes how to edit a parameter. - Deleting a Parameter
This section describes how to delete a parameter. - Implicit Parameters
This section describes the implicit parameters in the Resource Handler Details page. These parameters are automatically added to the resource handlers.
See Also:
About the REST Search ToolbarParent topic: Managing Resource Handlers
Creating a Parameter
This section describes how to create a parameter for a resource handler.
Parent topic: Viewing Resource Handler Details and Managing Parameters
Editing a Parameter
This section describes how to edit a parameter.
Parent topic: Viewing Resource Handler Details and Managing Parameters
Deleting a Parameter
This section describes how to delete a parameter.
Parent topic: Viewing Resource Handler Details and Managing Parameters
Implicit Parameters
This section describes the implicit parameters in the Resource Handler Details page. These parameters are automatically added to the resource handlers.
Table 4-1 Implicit Parameters
| Name | Type | Access Mode | HTTP Header | Description |
|---|---|---|---|---|
|
|
BLOB |
IN |
N/A |
Specifies the body of the request as a temporary BLOB. |
|
|
CLOB |
IN |
N/A |
Specifies the body of the request as a temporary CLOB. |
|
|
VARCHAR |
IN |
|
Specifies the MIME type of the request body, as indicated by the Content-Type request header. |
|
|
VARCHAR |
IN |
N/A |
Specifies the authenticated user for the request. If no user is authenticated, then the value is set to null. |
|
|
VARCHAR |
OUT |
|
Specifies the location where Oracle REST Data Services must forward a GET request to produce the response for this request. |
|
|
NUMBER |
IN |
N/A |
Specifies the zero-based offset of the first row to be displayed on a page. |
|
|
NUMBER |
IN |
N/A |
Specifies the maximum number of rows to be retrieved on a page. |
|
|
NUMBER |
IN |
N/A |
Specifies the zero based page offset in a paginated request. Note:
|
|
|
NUMBER |
IN |
N/A |
Specifies the maximum number of rows to be retrieved on a page. The |
|
|
NUMBER |
IN |
N/A |
Specifies the one-based index of the first row to be displayed in a paginated request. |
|
|
NUMBER |
IN |
N/A |
Specifies the one-based index of the last row to be displayed in a paginated request. |
|
|
NUMBER |
OUT |
|
Specifies the HTTP status code for the request. |
For more information about the implicit parameters, see Oracle REST Data Services Developer's Guide.
Parent topic: Viewing Resource Handler Details and Managing Parameters
Using Pre-Authenticated Requests to Access ORDS RESTful Services
To access protected RESTful services, you can create and revoke pre-authenticated requests.
Pre-authenticated requests enable you to access protected ORDS RESTful services without user credentials. When you create pre-authenticated request, a unique URL is generated. You can provide this URL to an external user to interact with the particular RESTful entity using standard HTTP tools.
For more information about Pre-Authenticated Requests, see Oracle REST Data Services Pre-Authenticated Requests in the Oracle REST Data Services Developer's Guide.
To navigate to the Pre-Authenticated Requests page, you can do either of the following:
-
From the Overview page, click the Pre-Authenticated Requests tile.
-
From the menu bar, expand Security and select Pre-Authenticated Requests.
Topics:
- Creating a Pre-Authenticated Request
- Viewing a Pre-Authenticated Request
- Revoking a Pre-Authenticated Request
Parent topic: Managing Resource Handlers
Creating a Pre-Authenticated Request
To create a pre-authenticated request for an existing handler:
-
From the context menu for an existing handler, select Create New Pre-authenticated Request.
The Create Pre-authenticated Request panel appears.
-
In the Token Expiration field, enter the token expiry duration in seconds.
Select Show Code to view the underlying source code for creating the pre-authenticated request.
Click Create.
The token, alias, and relative link to access the resource are displayed. You must keep track of the token and alias as you cannot obtain their values later. If you forget the values, you can revoke the token and create a new one again.
Viewing a Pre-Authenticated Request
From the context menu for an existing handler, select Pre-Authenticated Requests and then select Details.
The pre-authenicated requests for the specific handler appears.
Revoking a Pre-Authenticated Request
To revoke the pre-authenticated request for a handler:
-
From the context menu for an existing handler, select Pre-Authenticated Requests and then select Details.
The pre-authenticated requests for the specific handler appears.
-
From the context menu for the pre-authenticated request, select Revoke.
You are prompted to confirm.
- Click Confirm to revoke the request.
Example: Inserting a Record using a POST Handler
The following example illustrates how to insert a record in the DEPT table.
Prerequisites
-
Using the worksheet in the SQL page, create a DEPT table.
CREATE TABLE DEPT( DEPTNO number(2,0), DNAME varchar2(14), LOC varchar2(13), CONSTRAINT PK_DEPT PRIMARY KEY (DEPTNO) ) -
Create a module named example. See Creating a Resource Module
-
Create a template named emp/ for the module. See Creating a Resource Template
Parent topic: Creating RESTful Web Services



