cancel
Showing results for 
Search instead for 
Did you mean: 

Passing variables REST API

adgonzal
Champ in-the-making
Champ in-the-making
I'm trying to pass variables to the process when I create an instance via REST API but Im getting an error.

My process BPMN has declared this section:
<startEvent id="startevent2" name="Start" activiti:initiator="initiator">
      <extensionElements>
        <activiti:formProperty id="approver" name="Approver" type="user" required="true" />
        <activiti:formProperty id="duedate" name="Approval due date" datePattern="dd-MM-yyyy hh:mm" type="date"  />
        <activiti:formProperty id="invoiceNumber" name="Invoice Number" type="string" required="true"/>
   <activiti:formProperty id="invoiceAmount" name="Invoice Amount" type="long" />
   <activiti:formProperty id="supplierName" name="Supplier Name"    type="string" />
   <activiti:formProperty id="supplierNif" name="Supplier Nif"    type="string" />
   <activiti:formProperty id="supplierId"    name="Supplier ID"    type="string" />
   <activiti:formProperty id="companyName" name="Supplier Name"    type="string" />
   <activiti:formProperty id="companyNif" name="Supplier Nif"    type="string" />
   <activiti:formProperty id="companyId"    name="Supplier ID"    type="string" />
      </extensionElements>
    </startEvent>

and I send a JSON request qith these values:


{
  "processDefinitionKey":"invoicesApprovalProcess",
  "businessKey":"A1234567",
  "variables": [
      {
        "invoiceNumber":"A1234567",
        "invoiceAmount":"123",
   "supplierName":"supplierName",
        "supplierNif":"supplierNif",
   "supplierId":"supplierId",
        "companyName":"companyName",
   "companyNif":"companyNif",
        "companyId":"companyId",
   "approver":"kermit"
      }
  ]   
}

I think is not possible to assign form properties passing variables but….
How can I declare variables for the process?

The Rest API throws an Jackson UnrecognizedPropertyException; Unrecognized field "invoiceNumber"

Thanks in advance
2 REPLIES 2

frederikherema1
Star Contributor
Star Contributor
Please read the user guide for the format the variables should be in, when submitted. They differ from form-properties, as the variable type and name is explicitally declared in the REST-request to set them…

krull80
Champ in-the-making
Champ in-the-making
Hello,

Try this:

{
"processDefinitionKey":"invoicesApprovalProcess",
"businessKey":"A1234567",
"invoiceNumber":"A1234567",
"invoiceAmount":"123",
"supplierName":"supplierName",
"supplierNif":"supplierNif",
"supplierId":"supplierId",
"companyName":"companyName",
"companyNif":"companyNif",
"companyId":"companyId",
"approver":"kermit"
}

Regards