"Process Instance does not exists" via python REST call while it can be received via REST API and Cockpit

Short version:

I created a process with automatic tasks informing a backend about the beginning/end of the instance or tasks.
The backend is then called via the default http-connector with the id of the process instance in the body.
My backend receives the request fine and trys to call the camunda /task?processInstanceId=id and /process-instance/id endpoints with the id provided py the connectors request.
Using this id the REST-API returns Process instance with id … does not exist.
Taking a look at the cockpit or making a manual REST request the id works fine.

Camunda Specs

I run Camunda in a Docker container with default settings.

Server version name Apache Tomcat/9.0.33
Server built Mar 11 2020 09:31:38 UTC
Server version number 9.0.33.0
OS Name Linux
OS Version 5.6.10-arch1-1
Architecture amd64
Java Home valid path
JVM Version 11.0.4+4-alpine-r1
JVM Vendor Alpine

Backend Application

The backend is a python Django server, running with version 3.0.5.
Other requests to the camunda API work fine.
The code for the request:

    from requests import get as getrequest

    endpoint = f"process-instance/{id}"

    request = getrequest(
        url=camunda_rest_url + endpoint,
        headers={
            "content-type": "application/json"
        },
        data=None
    )

    return request

Long version:

A new process instance is started via the Camunda web client tasklist.
The first task in the process uses a http-connector to send a post request to the django backend containing only the process-instance id.
The backend trys to get the process via the /process-instance/id endpoint.
Camunda returns { 'type': 'InvalidRequestException', 'message': 'Process instance with id ... does not exist' }
The backend thread crashes because of currently nonexistent error handling.
Maybe Important: The request from the connector would only receive a response after the successful fetch of the process-instance and activity.
So when i try to reach the REST-API the request from the connector is sill pending. Could this be an issue?

Calling the API directly via insomnia works fine.
The instance is also listed in the Camunda Cockpit.

Other API calls to the Camunda REST-API using formated strings provided no issues.

Other code:

The endpoint called by the connector

def post(self, request, format=None):
        new_process(request) # trying to fetch the data
        return Response( # return response afterwards
            status=status.HTTP_200_OK
        )

Hi There,
Welcome to the community and thanks for the the well formatted question :slight_smile:

Can you upload your model please?
Which database are you using?
Also - what version of Camunda are you running exactly?

1 Like

This is the simple model I use for this test run.
isItThree.bpmn (11.6 KB)
The user chooses a number, an script asks if it is 3, the user can decide if the machine was right.
If yes, the process terminates, if no the machines can guess (3) again and so on…
At certain Points a http-connector is called to inform the backend.

The Camunda version is Community Platform v7.13.0

I didn’t connect a database to Camunda, as it isn’t necessary for the research project right now.


Further, your tutorial videos are awesome and were extremely helpful to understand the basics. Clearly superior to the competition (the docu aswell).

I’m delighted to hear that you’ve found the tutorials so useful :slight_smile: and thanks for the lovely complement.

So - i think the problem could be that the process only “comes into existence” after the first commit to the database has happened. With you process it seems that you’re asking the engine for the process ID before it’s actually been create.

What might solve the problem is if you tick the Asynchronous Before box at the Automatic IA ping task. Then you’ll force it to commit the state before it makes the call

1 Like

Thank you very much once again. This did the trick :grinning:

1 Like