Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderators: ArturoRobles, ArturoRobles

Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
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: ... 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 all
if (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();
Note: If using version 3.2, you will need to fix the source code for PMFAddInputDocument(). See:

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: ... pt-part-1/

The 500 Internal Server Error is the general catch[…]

Really very nice blog information for this one and[…]

This is a long, lengthy and cumbersome process. T[…]

Great read for when on the road. The book provides[…]