LinkedIn
Copied!

Table of Contents

Attachment management with DX API

DX API provides means of managing attachments for cases in your custom application. For example, you can use API endpoints to enable end users to attach receipts to expense reports in a non-Pega application.

This capability is available for Pega Platform™ 8.5 and later.

For more information about endpoints, requests, sample responses, error codes, and testing, see Accessing and testing DX API.

You can use DX API to manage attachments in the following ways:

Uploading files

Upload a file that you can later use as an attachment.

Endpoint: POST /attachments/upload

The request type is multipart form data. Even if the request contains multiple files, DX API processes only the first file in the request. The request body contains the following sequence: {context: string, content: <file>}. Without the context element, the attachment creation fails because immediate saving creates an instance of the Link-Attachment class. The response contains the pzInsKey property of the Link-Attachment class.

Sample response:

{
"ID": "44e79f89-e554-455a-adc5-b0f48cd5846f"
}

The response includes an ID that other endpoints require to process attachments.

Attaching uploaded files

Attach the file that you uploaded to a case.

Endpoint

  • Submit action: PATCH /assignments/{ID} /actions/{actionID}
  • Create case: POST /cases

The request uses the ID that POST /attachments/upload returns.

Sample response:

{
  "ID": "MYCO-PAC-WORK E-107",
  "pxObjClass": "Pega-API-CaseManagement-Case",
  "nextAssignmentID": "ASSIGN-WORKLIST MYCO-PAC-WORK E-110!PYSTARTCASE",
  "nextPageID": "Confirm"
}

Using the attachment gadget

Attach an object to a case regardless of the context or stage of the case life cycle. For example, you can attach a URL to a webpage or an object that is accessible through HTTP.

Endpoint: POST /cases/{caseID}/attachments

The request uses the ID that POST /attachments/upload returns.

Sample response:

{
"errorClassification": "Insufficient security",
"localizedValue": "User is not allowed to access or update the resource.",
"errorDetails": [
{
"message": "Error_No_Add_attachment_Access\tapis.pdf",
"errorCode": "",
"erroneousInputOutputFieldInPage": "",
"erroneousInputOutputIdentifier": "",
"errorClassification": "",
"errorCodeLabel": "",
"localizedValue": "Lack access to add apis.pdf.",
"messageParameters": []
}
]
}

Creating a list of attachments

Create a list of all the attachments of a given case.

Endpoint: GET /cases/{caseID}/attachments

Sample response:

{
"attachments": [
{
"extension": "pdf",
"fileName": "profile1.pdf",
"createdBy": "shars4",
"createTime": "2020-04-01T11:38:32.524Z",
"name": "profile",
"links": {
"download": {
"rel": "self",
"href": "/attachments/LINK-ATTACHMENT OPTRDJ-LOCALAPP-WORK R-10334!20200401T113832.524 GMT",
"title": "Download the attachment",
"type": "GET"
},
"delete": {
"rel": "self",
"href": "/attachments/LINK-ATTACHMENT OPTRDJ-LOCALAPP-WORK R-10334!20200401T113832.524 GMT",
"title": "Delete the attachment",
"type": "DELETE"
}
},
"ID": "LINK-ATTACHMENT OPTRDJ-LOCALAPP-WORK R-10334!20200401T113832.524 GMT",
"category": "Resume",
"type": "FILE"
},
{
"createdBy": "shars4",
"createTime": "2020-03-31T14:07:23.592Z",
"name": "yahoo",
"links": {
"download": {
"rel": "self",
"href": "/attachments/LINK-ATTACHMENT OPTRDJ-LOCALAPP-WORK R-10334!20200331T140723.592 GMT",
"title": "Retrieve the link",
"type": "GET"
},
"delete": {
"rel": "self",
"href": "/attachments/LINK-ATTACHMENT OPTRDJ-LOCALAPP-WORK R-10334!20200331T140723.592 GMT",
"title": "Remove the url",
"type": "DELETE"
}
},
"ID": "LINK-ATTACHMENT OPTRDJ-LOCALAPP-WORK R-10334!20200331T140723.592 GMT",
"category": "URL",
"type": "URL"
},
{
"extension": "pdf",
"fileName": "apis.pdf",
"createdBy": "shars4",
"createTime": "2020-03-20T12:23:40.543Z",
"name": "apis",
"ID": "LINK-ATTACHMENT OPTRDJ-LOCALAPP-WORK R-10334!20200320T122340.543 GMT",
"category": "FileNoAcess",
"type": "FILE"
}
]
}

Downloading attachments

Download the attachments of a given case.

Endpoint: GET /attachments/{attachmentID}

Sample response:

{
  "extension": "docx",
  "fileName": "myDoc.docx",
  "createdBy": "operator1",
  "createTime": "2020-05-14T15:01:38.932Z",
  "links": {
    "download/delete": {
      "rel": "self",
      "href": "/attachments/LINK-ATTACHMENT OPTRDJ-LOCALAPP-WORK I-2007!20200514T150138.932 GMT",
      "title": "Download the attachment",
      "type": "GET/DELETE"
    }
  },
  "ID": "LINK-ATTACHMENT OPTRDJ-LOCALAPP-WORK I-2007!20200514T150138.932 GMT",
  "category": "File",
  "type": "FILE"
}

Deleting attachments

Remove the attachments from a case.

Endpoint: DELETE /attachments/{attachmentID}

Sample response: Empty response with status code 200.

Creating a list of attachment categories

Create a list of available attachment categories.

Endpoint: GET /cases/{caseID}/attachment_categories

Sample response:

{
"attachment_categories": [
{
"canView": "false",
"canDeleteOwn": "true",
"canEdit": "false",
"name": "URL no access",
"ID": "URLNoAccess",
"canCreate": "true",
"canDeleteAll": "true"
}
]
}

Suggest Edit
Did you find this content helpful?

50% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.