Explain Service REST integration in Pega

A Service REST rule lets other systems call into your Pega application over HTTP. Where Connect-REST is Pega calling out, Service REST is Pega answering. A mobile app, a website or a partner system can then read or create cases and data through a URL.

The pieces you need

RuleJob
Service PackageThe container. It sets the authentication method and the processing mode (stateless or stateful)
Service RESTDefines the resource path and, for each HTTP method, the activity or data page that responds
Service activity or data pageDoes the work: reads or writes clipboard data
Data transforms or mappingConvert JSON in the request and response to and from clipboard properties

Building one

  1. Create or choose a Service Package and set authentication, for example basic or OAuth 2.0.
  2. Create a Service REST rule in that package. Give it a resource path, such as customers/{id}, where {id} is a path parameter.
  3. For each method you support, such as GET or POST, choose the service activity or data page and map the request and response data.
  4. Set the response status codes for success and for errors.
  5. Test with a tool such as Postman or curl, then publish the URL to the consumers.

A worked example

A bank wants a partner app to check a loan status.

  1. Resource path: loans/{loanId}/status, method GET.
  2. The service calls a data page D_LoanStatus with loanId as its parameter.
  3. The response mapping returns JSON such as {"loanId":"L-101","status":"Approved"} with status 200.
  4. If no loan exists, the service returns 404 with a short message instead of a Pega error page.

Good practice

  • Always require authentication and give the service account only the rights it needs.
  • Version your APIs, for example /v1/loans, so you can change them safely.
  • Validate the request and return clear error codes and messages.
  • Prefer stateless services and make each call carry its own context.
  • Log request IDs to help support trace a problem.

Interview tip

Name the rule chain: Service Package, Service REST, then the activity or data page and the mapping. Add one example URL. Read on: GET, POST, PUT, PATCH and DELETE in Pega integration.

No comments:

Post a Comment