REST API for importing processes

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

Moderator: amosbatto

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.
rohan0793
Posts: 2
Joined: Mon Jun 19, 2017 9:05 am
Country: India

REST API for importing processes

Unread postby rohan0793 » Mon Jun 19, 2017 9:06 am

Hi,

I am trying to work with the API to import a process in to process maker.

http://wiki.processmaker.com/3.2/REST_API_Designer#ImportProject

I passed the project_file variable as the path of the file but it gives me error saying that the file doesn't exist. But when I pass the same path in file_exist method, it returns true. Is that API endpoint functional? And if yes, how to use it?

Best,

amosbatto
Posts: 4904
Joined: Mon Jun 22, 2009 10:28 am
Country: Bolivia
Location: La Paz

Re: REST API for importing processes

Unread postby amosbatto » Mon Jun 19, 2017 11:40 pm

Are you using PHP? If so, then this code example won't work in PHP 5.5 and later:

Code: Select all

curl_setopt($ch, CURLOPT_POSTFIELDS, array(
         "project_file" => "@" . "/path_to_pmx_file/" . $filename
));

Instead you need to use this code:

Code: Select all

curl_setopt($ch, CURLOPT_POSTFIELDS, array(
         "project_file" => new CurlFile("/path_to_pmx_file/" . $filename)
));

If you are trying to use JavaScript, then forget about it, because the language doesn't allow the uploading of files.
Amos B. Batto ♦ ProcessMaker Technical Documentation Writer & Forum Manager ♦ Cofounder of ILLA-A

rohan0793
Posts: 2
Joined: Mon Jun 19, 2017 9:05 am
Country: India

Re: REST API for importing processes

Unread postby rohan0793 » Tue Jun 20, 2017 2:09 am

But I am using Guzzle for this. Do you have any idea how to do this with guzzle? I also tried to use postman, both by attaching a file and also by inputting the file path but no luck.

amosbatto
Posts: 4904
Joined: Mon Jun 22, 2009 10:28 am
Country: Bolivia
Location: La Paz

Re: REST API for importing processes

Unread postby amosbatto » Fri Jun 23, 2017 8:46 pm

You can't upload files using JavaScript, Postman or any similar tool. You have to use PHP or some other language which has access to the computer's file system.
Amos B. Batto ♦ ProcessMaker Technical Documentation Writer & Forum Manager ♦ Cofounder of ILLA-A


Return to “Developing processes & programming”

Who is online

Users browsing this forum: No registered users and 2 guests