Page 1 of 1

File upload from REST APIs

Posted: Mon Jan 06, 2020 10:12 am
by rohitambre
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.

Re: File upload from REST APIs

Posted: Tue Jan 07, 2020 1:11 am
by programerboy
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){
	echo 'ERROR UPLOAD<br/>';
} ... 1iw/videos