Start a process instance at a given task

Hello,

I’m trying to use the REST API to start a process instance at a given task. Looking at the documentation for the Start Process Instance API (Start Process Instance | docs.camunda.org) it looks like I should be able to do this using startInstructions.

I’ve also seen this post, Start a process instance in a specific task, but I’m still unable to get this working via the REST API. Everything I try results in a 400 response:

{
	"type": "InvalidRequestException",
	"message": ""
}

I also do not see anything in the Camunda logs to indicate what may be the issue.

Does anyone have an example of how to start a process instance at a given task using the REST API?

Can you show the request you’re using?

I can’t share the exact request. I will try to set up a sample flow that reproduces the issue that I can share.

In the meantime this is a representative example with JSON formatted to make it more readable:

POST /engine-rest/process-definition/key/test-flow/start HTTP/1.1
Host: ...
User-Agent: CamundaClientGo/{{version}}
Content-Length: ...
Authorization: Basic ...
Content-Type: application/json
Accept-Encoding: gzip
{
"variables": {
    "foo": {
        "value": "{...}",
        "type": "json",
        "valueInfo": {
            "objectTypeName": null,
            "serializationDataFormat": null
        }
    },
    "bar": {
        "value": "{...}",
        "type": "json",
        "valueInfo": {
            "objectTypeName": null,
            "serializationDataFormat": null
        }
    }
},
"businessKey": "5c3f97ae-db16-11e9-b1ef-8c859061fe68",
"startInstructions": {
    "type": "startBeforeActivity",
    "activityId": "human-approval-task",
    "variables": {
        "baz": {
            "value": "...",
            "type": "string",
            "valueInfo": {
                "objectTypeName": null,
                "serializationDataFormat": null
            },
            "local": false
        },
        "qux": {
            "value": "...",
            "type": "string",
            "valueInfo": {
                "objectTypeName": null,
                "serializationDataFormat": null
            },
            "local": false
        }
    }
},
"skipIoMappings": true
}

I’m including skipIoMappings as there is a DMN task before the task where I’m attempting to start the process instance which does set two process variables (baz and quz in this example) via I/O mapping.

A POST to start a process instance without startInstuctions or skipIoMappings works.

POST /engine-rest/process-definition/key/test-flow/start HTTP/1.1
Host: ...
User-Agent: CamundaClientGo/{{version}}
Content-Length: ...
Authorization: Basic ...
Content-Type: application/json
Accept-Encoding: gzip


{
    	"variables": {
    		"foo": {
    			"value": "{...}",
    			"type": "json",
    			"valueInfo": {
    				"objectTypeName": null,
    				"serializationDataFormat": null
    			}
    		},
    		"bar": {
    			"value": "{...}",
    			"type": "json",
    			"valueInfo": {
    				"objectTypeName": null,
    				"serializationDataFormat": null
    			}
    		}
    	},
    	"businessKey": "5c3f97ae-db16-11e9-b1ef-8c859061fe68"
}

A few more details, I’m using Camunda 7.13 standalone via docker and the https://github.com/citilinkru/camunda-client-go client.

Thanks!

The issue ended up being my client. It is not properly marshaling startInstructions as a JSON array. Once I made startInsructions a JSON array I was able to start the process instance as desired.

1 Like