There is currently no way to send an Input Document in JSON to ProcessMaker with REST. For that reason, you have to use PHP, Python, Java or a similar server side language to send files to ProcessMaker with REST. It is currently not possible with JavaScript (or a similar browser-side language).
See:
http://wiki.processmaker.com/3.0/REST_A ... t-document
What programming language are you using?
I don't recommend doing this, but there are workarounds. For example, you could create a trigger like this in one of your ProcessMaker processes:
Code: Select allif (isset(@@sFileBase64) and !empty(@@sFileBase64)) {
$sContentsDecoded = base64_decode(@@sFileBase64);
$sFilename = tempnam("C:\mydir", "pm_");
if ($sFilename === false) {
throw new Exception("Unable to create temporary file");
}
file_put_contents($sFilename, $sContentsDecoded);
$inpDocId = "XXXXXXXXXXXXXXXXXXXXXXXXX"; //set to the unique ID of the Input Document
@@newFileId = PMFAddInputDocument($inpDocId, null, 1, 'INPUT', '', 'Add',
@@APPLICATION, @%INDEX, @@TASK, @@USER_LOGGED, 'file', $sFilename);
if (!empty(@@newFileId)) {
require_once 'classes/model/AppDocument.php';
$aProps = array(
'APP_DOC_UID' => @@newFileId,
'DOC_VERSION' => 1,
'APP_DOC_FILENAME'=> @@newFilename
);
$oDoc = new AppDocument();
$oDoc->update($aProps);
}
}
Note: If using version 3.2, you will need to fix the source code for PMFAddInputDocument(). See:
http://bugs.processmaker.com/view.php?id=22881
Then, in your external script, you need to convert the file to base64 and store it in a variable. For example, in PHP, you could do something like this:
Code: Select all$sFileBase64 = base64_encode(file_get_contents("C:\MyDir\MyFile.ext"));
$newFilename = "MyFile.ext";
Then, send sFileBase64 and newFilename as variables to a case in ProcessMaker with the
PUT /cases/{app_uid}/variable endpoint.
Then, execute the above trigger with the
PUT /cases/{app_uid}/execute-trigger/{tri_uid} endpoint.
I haven't tried the above code, so it might take some debugging, but it gives you the basic idea. If you are using JavaScript, see:
https://www.nczonline.net/blog/2012/05/ ... pt-part-1/