Tech-Docs

Creating New Cases Using Pega DX API

Table of Contents

Overview

The Pega Digital Experience (DX) API provides a set of model-driven REST API endpoints that enable developers to programmatically view, create, and update cases and assignments. This API is particularly useful for web self-service use cases, where it is important to align your user experience with your digital strategy while continuing to enable your business users to define and modify your application cases and user interface within Pega’s low-code model.

Prerequisites

Before you start, ensure you have:

Steps to Create a Case

1. Set Up Authentication

To access the Pega DX API in Pega Infinity or Pega Launchpad, you need to authenticate your requests. This typically involves setting up an authentication profile and resource path.

2. Generate Microservice Code

In Pega Infinity, navigate to the case type you want to use. On the Settings tab, click Integration, and under Microservice APIs, click Generate create case microservice code. This will generate the necessary code and data transforms.

3. Create the Request Body

The request body for creating a case typically includes the case type ID, process ID, parent case ID, and content. The content node should contain the required fields for the case.

Example Request Body:

{
  "caseTypeID": "YourCaseTypeID",
  "processID": "",
  "parentCaseID": "",
  "content": {
    "FieldName1": "Value1",
    "FieldName2": "Value2"
  }
}

4. Add Fields to Allow Starting Fields

After preparing the JSON, add the request body fields to the “Allow Starting Fields” section.

5. Generate Token

Before making the API call, generate an access token using your client credentials.

Example Token Request:

Example Token Response:

{
  "access_token": "YourAccessToken",
  "token_type": "Bearer",
  "expires_in": 3600
}

6. Make the API Call

Use the generated request URL, HTTP authentication header, and request body to make the API call in Pega Infinity or Pega Launchpad. Here’s an example of how to make the API call:

Example API Call:

Request:

7. Verify the Case Creation

After making the API call, verify that the case has been created successfully in Pega Infinity or Pega Launchpad. Retrieve the etag value from the response headers for future reference.

  1. Check the Response: Ensure the API response indicates a successful case creation. Look for a status code of 201 Created and a body containing the case details.
  2. Log in to Pega Infinity or Pega Launchpad: Go to your Pega instance and search for the newly created case using its ID.
  3. Review Case Details: Verify that all the fields and data have been correctly populated as per your request.

8. Handling Complex Data Types in Pega Launchpad

If the request body includes complex data types, you can use a PATCH call with embedded data to handle these scenarios.

Example Embed Data Call:

Explanation of Operations

  1. INSERT Operation:
    • Target: .Arms
    • Description: This operation is inserting a new item into the “Arms” list at the specified index.
    • Purpose: To add a new arm group to the case.
  2. UPDATE Operation:
    • Target: .Arms
    • Description: This operation updates the existing item in the “Arms” list by setting the ArmGroupLabel to “Group A”.
    • Purpose: To update the label for the existing arm group.
  3. INSERT Operation:
    • Target: .Arms(1).Visits
    • Description: This operation inserts a new visit into the “Visits” list within the first arm group.
    • Purpose: To add a new visit entry to the arm group.
  4. UPDATE Operation:
    • Target: .Arms(1).Visits
    • Description: This operation updates the existing visit with details such as VisitName, Category, Duration, DurationType, and Notes.
    • Purpose: To update the details of the existing visit.
  5. INSERT Operation:
    • Target: .Arms(1).Visits(1).ProcedureList
    • Description: This operation inserts a new procedure into the “ProcedureList” within the first visit of the first arm group.
    • Purpose: To add a new procedure entry to the visit.
  6. UPDATE Operation:
    • Target: .Arms(1).Visits(1).ProcedureList
    • Description: This operation updates the existing procedure with details such as ProcedureName, ProcedureCost, and Notes.
    • Purpose: To update the details of the existing procedure.

Each of these operations is designed to either add new data (INSERT) or modify existing data (UPDATE) within the case structure, ensuring the case data is accurately maintained and updated as needed.

Additional Resources

For more detailed information, refer to the Pega DX API Documentation.

Troubleshooting

If you encounter any issues, check the following:

Conclusion

Using the Pega DX API in Pega Infinity and Pega Launchpad, you can create cases programmatically, aligning your user experience with your digital strategy while leveraging Pega’s powerful case management capabilities.