Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
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.
#827364
Hello everyone! I have been using processmaker for a couple of weeks and today I found an issue related to triggers that I have not been able to solve.
I have a form where customer items are created, and during this time I've been writting my code for the triggers using VSCode. The trigger's function is to send data collected from the form to an external api using php cURL but the thing is that executing the trigger directly from the cli returns a 201 response, creating the contact without any issue, but whenever I place and execute the same trigger inside Processmaker(I set the trigger to execute after the dynaform), the process continues to the next step, no error code is given, but the customer doesn't appear on the api. I have read and configured the debbugger as best I could, but since there is no real error, I never get a clue about what could be happening.

Two things to note:
1. Since some fields are dependant on external data, I am hardcoding the values, just to test.
2. I will not be posting the url nor the Authorization for security reasons, but as I said, everything is there and working when outside PM.

This is the trigger I am referring to:
Code: Select all
$contactEmail = @@formContactEmail;
$contactReseller_id = 2; 


$dataArray = array(
	"email" => "prueba@prueba.es", //$contactEmail,
	"reseller_id" => $contactReseller_id
);

	
$ch= curl_init();

$uri = $url;
$options = array(
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_SSL_VERIFYHOST => false,
	CURLOPT_SSL_VERIFYPEER => false,
	CURLOPT_POST => true,
	CURLOPT_POSTFIELDS => json_encode($dataArray),
	CURLOPT_URL => $uri,
	CURLOPT_HTTPHEADER => array("Content-Type: application/json", "Authorization:")
);
curl_setopt_array($ch, $options);

curl_exec($ch);

$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
Thank you so much for your help. Have a nice day!


---------EDIT--------
After reading and searching for more info, I am now wondering if the trigger must be called in any way: Do I need to do something more to call the trigger? I just placed it after the dynaform and the debugger is also showing it whenever I run the process so I suspect this is not the issue, but I am not sure. Thank you again!
#827367
Hi jbernues,

All requests of a ProcessMaker need to include the access token in the HTTP header. You're not including the token, add the token like the example:

$ch = curl_init("https://example.com/api/1.0/workflow/users");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer 38d25eab20873124becc8948df03e14519f93695"));

If you have more information about this. Please click on the following link: https://wiki.processmaker.com/3.0/Calli ... points#PHP

Please, let me know if you have any doubts.

Regards.
#827368
Hello dan123dan! Thank you for your answer, I did not include the token for security reasons, I am kind of new to Rest Apis and I thought it was not a good idea to copy the token, you can see that I didn't include the url as well. But with both token and url properly placed inside the code, when I put it inside a trigger in PM it won't create a customer object inside the api, but it does when I use php cli and execute my apiCreateCustomer.php file.
There is no error report in the debbuger, the process starts and finishes ok, but the data is not uploaded.

Thank you again! Best regards.
#827375
Hi everyone! I am still stuck with this issue. I have been doing other stuff meanwhile, but after coding more triggers and trying the out, the result is the same: No error/warning given by processmaker debbuger, no sign of the trigger in chrome's DevTools, but executing it from the CLI with php and cURL works perfectly fine. I have also been searching for logs hoping to clarify this situation, which do not seem to exists or at least, provide any info on triggers.
PM wiki states that logs are stored either inside <INSTALL-DIRECTORY>/workflow/engine/config/env.ini or <INSTALL-DIRECTORY>/shared/sites/WORKSPACE/env.ini but I find no env.ini inside workflow->config and shared is just empty, so no logs there as well. Any tip on this?
Any help will be much appreciated, I don't really know what else to do or where to look for more information.
Thank you again!
Best regards.
#827385
Hi jbernues,

Try using this on the terminal:

tail /opt/processmaker/shared/sites/workflow/log/processmaker-20XX-X-X.log

Using this you could see more information about the execution of the trigger.

Please, let me know how this is going.

Regards.
Want to create your own meme coin?

In the world of cryptocurrencies, a unique and exc[…]

The market for cryptocurrencies is demonstrating a[…]

What's SAP FICO?

Embarking on a dissertation can be one of the most[…]

Hello. For rental housing, there are software solu[…]