0 votes
1.0k views
in REST API by

1 Answer

0 votes
by (30.6k points)

The BPM document store accepts uploads through the classic REST API as a multipart request; the document is attached to a process instance (or stays unattached) and can carry properties:

# upload (multipart/form-data): file part + metadata as query parameters
curl -k -u user:pw -H "BPMCSRFToken: $TOKEN" \
  -F "file=@invoice.pdf;type=application/pdf" \
  "https://host:9443/rest/bpm/wle/v1/document?name=invoice.pdf&processInstanceId=2072.123&documentType=INVOICE&properties=%7B%22vendor%22%3A%22Acme%22%7D"
# response: { "data": { "id": "2074.987", "name": "invoice.pdf", "mimeType": "application/pdf", "size": 12345, "url": "/rest/bpm/wle/v1/document/2074.987/content" } }

# download
GET /rest/bpm/wle/v1/document/2074.987/content
# list the documents of an instance
GET /rest/bpm/wle/v1/process/2072.123?parts=documents
# update content (new version) / delete
POST /rest/bpm/wle/v1/document/2074.987?action=update  (multipart file)      DELETE /rest/bpm/wle/v1/document/2074.987
// browser (coach view): upload a File object from an <input type=file> to the current instance
var fd = new FormData(); fd.append("file", input.files[0]);
var xhr = new XMLHttpRequest();
xhr.open("POST", base + "/rest/bpm/wle/v1/document?name=" + encodeURIComponent(input.files[0].name) + "&processInstanceId=" + piid, true);
xhr.setRequestHeader("BPMCSRFToken", token);
xhr.onload = function () { if (xhr.status === 200) ${DocList}.refresh(); };
xhr.send(fd);

Notes: parameter names vary slightly by release (processInstanceId vs parentId on 8.5.0; check the REST API tester /bpmrest-ui of your level), the document store must be enabled (it is by default), size limits come from the web container's maximum post size (raise it for large files), and for ECM (FileNet) the equivalent is the CMIS AtomPub / browser binding of the content server, not the BPM document resource. In service flows use tw.system.createDocument instead of REST (question 104).

References

Related questions

0 votes
1 answer 1.9k views
0 votes
1 answer 2.1k views
0 votes
1 answer 2.6k views
0 votes
1 answer 2.2k views
asked May 15, 2016 in REST API by BPM Tips Admin (21.5k points)
0 votes
1 answer 997 views
asked May 15, 2016 in REST API by anonymous
0 votes
1 answer 826 views
0 votes
1 answer 2.2k views
0 votes
1 answer 1.6k views
0 votes
1 answer 2.9k views
0 votes
1 answer 2.5k views
0 votes
1 answer 1.2k views
0 votes
1 answer 762 views
+1 vote
1 answer 1.8k views
0 votes
2 answers 4.6k views
0 votes
1 answer 1.5k views
0 votes
1 answer 717 views

723 questions

807 answers

98 comments

4.9k users

Join BPM Community Discord Channel

Welcome to BPM Tips Q&A, Community wiki/forum where you can ask questions and receive answers from other IBM BPM experts and members of the community. Users with 2000 points will automatically be promoted to expert level.
Created by Dosvak LLC
Our Youtube Channel
...