Error while validating expected inputs: [Expected input [travelRequestInput] is missing] creating a case in REST API

I’ve followed the getting started tutorial at https://documentation.bonitasoft.com/?page=getting-started-tutorial and now I’m trying to start a case using the REST API.

After calling loginservice, I’m sending a POST and getting and error 500, with the following message:

{“exception”:“class org.bonitasoft.web.toolkit.client.common.exception.api.APIException”,“message”:“Data definition travelRequest doesn\u0027t exists for process 7525863855240002967”,“api”:“bpm”,“resource”:“case”}

The body of my request looks like this:

{
“processDefinitionId”:“7525863855240002967”,
“variables”:[
{
“name”:“travelRequestInput”,
“value”:
{
“userId”: 4,
“destination”: “LONDON”,
“departureDate”: “2017-12-09”,
“numberOfNights”: 8,
“hotelNeeded”: true,
“reason”: “”,
“status”: “pending”,
“refusalReason”: “”
}
}
]
}

I’ve also tried with this:

{
“processDefinitionId”:“7525863855240002967”,
“variables”:[
{
“travelRequestInput” :
{
“userId”: 4,
“destination”: “LONDON”,
“departureDate”: “2017-12-09”,
“numberOfNights”: 8,
“hotelNeeded”: true,
“reason”: “”,
“status”: “pending”,
“refusalReason”: “”
}
}
]
}

and this:

{
“processDefinitionId”:“7525863855240002967”,
“travelRequestInput” :
{
“userId”: 4,
“destination”: “LONDON”,
“departureDate”: “2017-12-09”,
“numberOfNights”: 8,
“hotelNeeded”: true,
“reason”: “”,
“status”: “pending”,
“refusalReason”: “”
}
}

And the exceptions turns into:

{“exception”:“class org.bonitasoft.web.toolkit.client.common.exception.api.APIException”,“message”:“Error occured when starting process 7525863855240002967”,“cause”:{“exception”:“class org.bonitasoft.engine.bpm.process.ProcessExecutionException”,“message”:“USERNAME=walter.bates | org.bonitasoft.engine.bpm.contract.ContractViolationException: Error while validating expected inputs: [Expected input [travelRequestInput] is missing]”},“api”:“bpm”,“resource”:“case”}

I can’t figure out if its a problem in the API call or in the process definition.

Thanks in advance

I’ve found the solution in the documentation itself.

To instantiate a process mapping BDM variables the right endpoint to use is:

/API/bpm/process/:processId/instantiation

In my case the URI looks like this:

http://localhost:8080/bonita/API/bpm/process/8261464674502160363/instantiation

And the payload is:

{
“travelRequestInput” :
{
“userId”: 4,
“destination”: “LONDON”,
“departureDate”: “2017-12-09”,
“numberOfNights”: 8,
“hotelNeeded”: true,
“reason”: “”,
“status”: “pending”,
“refusalReason”: “”
}
}

That’s all.

Best regards,