Exposing an application as a service
The two most common ways to expose your application as a service are either to use the Pega API or create a web service with the Service Wizard.
Conceptually, these two options work the same way by making a request to a URL, and then receiving a response. The difference is in how you communicate with the service.
Pega API communicates in more generic terms about the resources of your application, such as Cases. For example, you use Pega API if an external application requires a list of Case attachments or needs to retrieve Case details and make subsequent calls to update. You can use multiple Pega API services as part of single or multiple application Processes.
Pega API provides a standard set of services that includes new Case creation, Assignment processing, and access to Data Pages. These built-in REST/JSON services enable rapid implementation of Pega-powered mobile and client applications.
You can call any of the Pega API services by using standard HTTP methods (for example, GET, POST, or PUT). To see details of the request and response data requirements, view the Pega API resources page in Dev Studio or App Studio:
- In Dev Studio, click the Resources menu, and then select Pega API.
- In App Studio, click Channels, and select API.
The following resources are available through Pega API:
|Obtain a list of Assignments for a user, obtain the details of any specific Assignment, and perform an Assignment Action.
|Verify user credentials.
|Obtain a list of Cases for a user, create a new Case, obtain Case details, and update a specific Case.
|Obtain a list of Case Types for the authenticated user.
|Facilitate the process of obtaining the contents of a Data Page and obtaining the metadata for a specific Data Page.
|Access complete documentation for Pega API.
Note: For more information about Pega API, see Integrating with APIs and services. Documentation is also available in the JSON format in the Docs API (GET/docs).
Consider the use case of an application that allows electric vehicle drivers to report issues with city-owned chargers. As users encounter an issue, they access the application and report the issue. A city employee then reviews the issue report for further action. The Pega API interactions include:
- Log in to the app by calling GET /authenticate.
- View the list of possible issues to report by calling GET /casetypes.
- View the list of city regions by calling GET /data/D_CityRegionList.
- Select an issue and a city region.
- Submit the report by calling POST /cases.
- View all submitted reports by calling GET /cases.
- Open a specific report to view details by calling GET /cases/ID.
The Pega API page defaults to Constellation DX API. To change to Traditional DX API, select Traditional APIs from the Service package list.
Because Pega API is resource-oriented and not Action-oriented, if you need to perform a particular Action such as having an external caller notify a Pega Platform application that a specific event has occurred, you need to build or use a custom API using the Service Wizard. When you use custom APIs, you can define the requests and responses more specifically by using the actual Data Model of your application. You can create custom REST/JSON services for external systems to integrate with your Pega Platform applications to request, receive, send data, or invoke an Action.
For example, an external application needs to access insurance policy details and then notify your application to process a specific event. You expose a REST service with the required parameters and provide a response with those policy details to the external application.
Tip: Before selecting which API you need, familiarize yourself with the Pega Platform™ Data Model so that you can correctly format requests and understand responses from Pega API.
Access the Service Wizard by clicking Configure > Integration > Services > Service Wizard. The Service Wizard generates Rules and Data Types for services that perform one of the following tasks:
|Create and manage work
|Create new work items or perform Actions on a work object such as a Flow Action.
|Invoke existing activity Rules
|Call an activity and select service parameters.
|Process input or output data
|Map data to or from the Clipboard.
The Service Wizard completes each of these tasks through five general steps, for which the Service Wizard displays a sequence of forms to fill out that define the appropriate service Rules and the supporting data types. Some service purposes may contain more substeps than others because of the nature of their configuration. When you finish, the Service Wizard displays the values that you specified, which you can then review and modify before creating the service Rules.
In the following image, click the + icons to learn more about the five general steps of the Service Wizard:
Check your knowledge with the following interaction: