Start process with variables posted by Jquery Ajax

Dear community,
I try to start a workflow, initiated by a JQuery Ajax Post request from my website. This works well if I put no data on it.

$('#start-workflow-button').on('click', function() {
        $.ajax({
            url: 'http://sma6434:8081/engine-rest/process-definition/key/ToolingWorkflow/submit-form',
            method: "POST",
            contentType: "application/json",
            dataType: 'json',
            
            success: function(result){
                console.log(result);
            }
        })
    })

Now I add some JSON:

$('#start-workflow-button').on('click', function() {
        $.ajax({
            url: 'http://sma6434:8081/engine-rest/process-definition/key/ToolingWorkflow/submit-form',
            method: "POST",
            contentType: "application/json",
            dataType: 'json',
            data: {
                "variables": {
                    "myrequest" : {
                    "value" : "aStringValue",
                    "type": "String",
                    "valueInfo" : {
                        "transient" : true
                        }
                    }
                },
                "businessKey" : "myBusinessKey"
            },
            success: function(result){
                console.log(result);
            }
        })
    })

This leads to a response of 400 with the body of {"type":"InvalidRequestException","message":""}

The picture below shows how I setup the entrypoint of the Process

image

below the JSON of the connected form

{
  "schemaVersion": 2,
  "components": [
    {
      "label": "myrequest",
      "type": "textfield",
      "id": "Field_1tnyq7k",
      "key": "myrequest",
      "validate": {
        "required": false
      },
      "description": "some text from external app"
    }
  ],
  "type": "default",
  "id": "Form_1nxvfgw"
}

Has somebody an idea what is going wrong here?

Thanks a lot for your help

Michael

Hello,
I defined the process variables now directly in the startEvent without referenceing to a form by a key.

<bpmn:process id="ToolingWorkflow" isExecutable="true">
    
    <bpmn:sequenceFlow id="Flow_1ao5pyj" sourceRef="StartEvent_1" targetRef="validateTheRequest" />
    <bpmn:sequenceFlow id="Flow_0iy6o0p" sourceRef="validateTheRequest" targetRef="Event_19ijvhc" />
    
    <bpmn:startEvent id="StartEvent_1" name="someone has a request for something">
      <bpmn:extensionElements>
        <camunda:formData businessKey="myrequest">
          <camunda:formField id="myrequest" label="myrequest" type="string" defaultValue="lorem" />
        </camunda:formData>
      </bpmn:extensionElements>
      <bpmn:outgoing>Flow_1ao5pyj</bpmn:outgoing>
    </bpmn:startEvent>
    
    <bpmn:userTask id="validateTheRequest" name="validate the request" camunda:formKey="camunda-forms:deployment:FLMvalidationForm.form">
      <bpmn:incoming>Flow_1ao5pyj</bpmn:incoming>
      <bpmn:outgoing>Flow_0iy6o0p</bpmn:outgoing>
    </bpmn:userTask>
    
    <bpmn:endEvent id="Event_19ijvhc" name="Request is accepted">
      <bpmn:incoming>Flow_0iy6o0p</bpmn:incoming>
    </bpmn:endEvent>
   
  </bpmn:process>

I changed my Ajax call as well slightly

$('#start-workflow-button').on('click', function() {
		$.ajax({
			url: 'http://sma6434:8081/engine-rest/process-definition/key/ToolingWorkflow/submit-form',
			method: "POST",
			contentType: "application/json",
			dataType: 'json',
			data: {
				"variables": {
					"myrequest" : {
						"value" : "aStringValue",
						"type": "String",
						"valueInfo" : {}
					}
				},
				"businessKey" : "myBusinessKey"
			},
			success: function(result){
				console.log(result);
			}
		})
	})

Unfortunately I still get the same result

Key Value
Response HTTP/1.1 400
Content-Type application/json
Transfer-Encoding chunked
Date Thu, 07 Oct 2021 05:03:00 GMT
Connection close
{"type":"InvalidRequestException","message":""}