I am building a prototype and I have a setup with Camunda BPM Run running on a docker container. I am trying to keep it as lightweight as possible, so there is no java backend, but all the needed code is in the process as inline scripts.
In the process I upload a pdf file, using an embedded html form. I then need to include this file to the payload of a rest call. I am using HTTP Connectors for the rest calls.
I am currently trying to convert the file to Base64 string and include it in the message, but it is unsuccessful. Are there any other suggestions?
I also get the message “An exception occurred in the persistence layer. Please check the server logs for a detailed message and the entire exception stack trace.”
But I am not sure on where I should check for the additional info? I see nothing in the console…
In case more info is needed, I would be happy to provide.
to overcome this limitation of the connectors I recommend to switch the implementation of the service task to
External and provide an external task worker in a programming language of your choice to do the upload.
You gain a lot more control over all requirements.
Here is some documentations of external tasks: https://docs.camunda.org/manual/7.14/user-guide/process-engine/external-tasks/.
And here is a list of available external task workers: https://github.com/camunda/awesome-camunda-external-clients
Hope this helps, Ingo
Thank you for the reply. This would be a convenient workaround for me…
Is there a way to pass the file (as InputStream) from the process to the external task?
Prefferably, I would use python for the external task…
I currently have the following solution:
- Upload file with an embedded form (will be saved as ByteArrayInputStream in a camunda variable)
- Transfer control to an external task (implemented in python, following this tutorial: https://github.com/camundacon2019/External-Task-Client)
- The external task has the following logic:
Then I continue with my business logic.
Although this solution works,it seems a bit “dirty” to me? Is there not a more straightforward way to pass the file variable in the external task?
to reduce the payload of the initial fetch-and-lock call, you have to get the file variable content separately in your worker code.
A shortcut is possible:
The processInstanceId is included in the fetchAndLock reponse. You can use this to access the variable content directly and skip your first GET request in your logic.
Hope this helps, Ingo
As I am new to Camunda - just evaluating it for my company - I am probably missing something…
Here is what I try:
Upload locals files with embedded form (I got that part). I can find the files as task variables “loadHistoryFile” and “configFile”.
I tested the REST-API call separately and it works.
Here the worker code:
The REST-call in postman looks like this:
Can you give me a hint how to send the files?
You don’t need to implement an additional service task for sending the variables. In the implementation of your external task, you need to perform a GET request to Camunda, as I described in step 3 of my reply.
Background: External Tasks are implemented with polling architecture. I.e., Camunda knows nothing about them. The logic of camunda regarding external tasks is: “I don’t care how / but I need this job done”. Therefore, the task has to request the required information from Camunda itself.
Hope this helps?