Attachment management with DX API v2
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.
For more information about endpoints, requests, sample responses, error codes, and testing, see Accessing and testing Pega DX API Version 2.
Uploading files
Upload a file that you can later use as an attachment.
- Endpoint
POST /attachments/upload
- 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.- Submit action:
- 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" } ] }
Previous topic Adding fields while creating cases in DX API v2 Next topic Accessing and testing Pega DX API Version 2