Pega API - /api/v1/cases can we add doc as base64

Hi,

We have a requirement where we are trying to create a case but we only have the PDF as a base64 encoded string. We do not store documents on our server and we pull this information on the fly. Is there a way for us to send this base64 string in the case creation request?

Hello @MarvinT

I have a few clarifying questions after reading your requirement, because the approach can vary depending on how the case is being created and how the PDF is intended to be used.

  1. From where are you creating the case?

    1. Is it from a non-Pega application through DX API / Case API?
    2. Or is the case being created within another Pega process?
  2. What is the purpose of the PDF in this flow?

    1. Is the PDF only meant to be attached to the created case?
    2. Or does Pega need to read/extract data from the PDF to populate case fields?
  3. Is the case creation triggered as part of another orchestration flow where:

    1. You receive the PDF from an external system, and
    2. Immediately create a new case using that document?
  4. What volume and size are we talking about?

    1. Approximate PDF size (KB/MB)?
    2. Single document or multiple documents per case?
  5. Are you expecting the PDF to be stored in Pega as an attachment, or do you want it processed transiently without persistence?

  6. Which Pega version are you using now ?

Generally, it is not suggested to pass base64 encoded string directly in the DX API. I believe you might have already looked at the standard upload attachment DX API here - Pegasystems Documentation

But this will store the information in Pega DB or a repository, depending upon the application configuration.

With a bit more context on the integration pattern and intended document handling, it would be easier to suggest next actions.

Regards

JC

  1. From where are you creating the case?

    1. Is it from a non-Pega application through DX API / Case API?
      1. This is from a Pega application to another Pega application through Traditional Case API
  2. What is the purpose of the PDF in this flow?

    1. Is the PDF only meant to be attached to the created case?
      1. This needs to attach to the created case as the downstream party will utilize that information. Our current Pega application is not a SOR for documents, and so we have links to our document system within our org. However, the application that we are triggering case creation for does store docs on their side as they do not have access to the doc system.
  3. Is the case creation triggered as part of another orchestration flow where:

    1. You receive the PDF from an external system, and
    2. Immediately create a new case using that document?
      1. Yes, we retrieve that PDF temporarily and then would create a new case in the other system using that document.
  4. What volume and size are we talking about?

    1. Approximate PDF size (KB/MB)?
      1. ~100KB
    2. Single document or multiple documents per case?
      1. This would be a single document.
  5. Are you expecting the PDF to be stored in Pega as an attachment, or do you want it processed transiently without persistence?

    1. This would need to be stored as an attachment in the second application, but we don’t store it on ours.
  6. Which Pega version are you using now ?

    1. 23.1.5

Yes, you can pass the attachement during the case creation. However, you have to the pass attachment id instead of base 64 string.

{
  "caseTypeID": "MyCo-PAC-Work-ExpenseReport",
  "processID": "pyStartCase",
  "parentCaseID": "MyCo-PAC-Work D-09",
  "content": {},
  "pageInstructions": [
    {
      "instruction": "APPEND",
      "target": "myPageList",
      "listIndex": "3",
      "groupIndex": "Customer",
      "listMoveToIndex": "5",
      "content": {}
    }
  ],
  "attachments": [
    {
      "type": "File",
      "attachmentFieldName": "myAttachmentField",
      "category": "myFile",
      "name": "myAttachment",
      "ID": "213e8449-102e-492d-b883-afdf64da0d78",
      "delete": "false"
    }
  ]
}

You have to use Upload API to get the attachment ID and then pass it during the case creation - Pegasystems Documentation

This document comes to me as a base64 string, as we do not store it on our app. Is there anything within Pega that I can use to convert it and send it during case creation?

As part of the DX API, it expects the attachment ID. However, you need to build a Custom API to achieve it with the following options,

Option1:

  1. DX API for case creation
  2. Custom API for sending the base 64 string + CaseID
  3. In the Activity rule, you can attach it to the case.

Option 2:

  1. Custom API for sending the base 64 string + other parameters
  2. In the Activity rule, create the case and then you can attach it to the case.