Questions and discussion about using ProcessMaker: user interface, running cases & functionality
By rohitambre
#827309
Hi everyone,

I want to use Processmaker's REST APIs to perform all activities of process. Processmaker's documentation is quite good and I am able to perform actions but I'm stuck at file upload from single, multi file and grid file upload.

I read other posts about the same and I am also using ExtraRest plugin which is really very helpful but I was unable to find an API to upload files only through any javascript Frontend library.

Can anyone help me for FIle upload from REST endpoints.
User avatar
By programerboy
#827313
Hi,
You can use a code like this:
Code: Select all
function uploadInputDocument($caseId, $taskId, $inputDocId, $inputDocComment, $filePath)
{
	$aVars = array(
	   'inp_doc_uid'     => $inputDocId,
	   'tas_uid'         => $taskId,
	   'app_doc_comment' => (!empty($inputDocComment)?$inputDocComment:'This is from webserice!'),
	   'form'            => (phpversion() >= "5.5") ? new CurlFile($filePath) : '@' . $filePath
	);
	
	return pmRestRequest('POST', $_SERVER['HTTP_HOST'], '/api/1.0/'.config("system.workspace").'/cases/'.$caseId.'/input-document', $aVars);
}

$document = uploadInputDocument($caseId, $taskId, $inputDocId, 'your file comment', 'your path file');
if($document->status == 200){
	print_r($document->response);
}
else{
	echo 'ERROR UPLOAD<br/>';
	print_r($document);
}
https://pmlearning.info
Thanks

💥 Join the Exclusive Trading Community and Experie[…]

Briefly introduce the topic and provide context. S[…]

If you want to know the best technique to export P[…]

Nursing dissertation help topics

Home of Dissertations is the most used platform th[…]