Can't complete a task and send variables using the Tasklist REST API

Hello, everyone!

So, I’ve encountered a bit of a roadblock. I have a process where, through a form, a user requests vacations. Then, their answers are checked by another user. Initially, I was doing everything with Tasklist. Now, I’m starting to migrate everything to my own webapp.

So, what exactly is the problem? To test, I’m using the Swagger UI for Tasklist. This is what I’ve done.

  • I get the taskId through a request to the /v1/tasks/search endpoint. Works fine.
  • I assign the task to a certain user through the /v1/tasks/{taskId}/assign endpoint. Also works fine.
  • I then try to complete the task through the /v1/tasks/{taskId}/complete endpoint, and I specify in the body my variables as shown next:
{
    "variables": [
        {"name": "fechaInicio", "value": "10.10.2023"},
        {"name": "fechaFin", "value": "10.11.2023"},
        {"name": "razon", "value": ["vacaciones"]}
    ]
}

However, when I execute this last API call, I get a 500 internal server error as a response.

I’ve tried formatting the variables different, but the outcome keeps being the same. I don’t know If this is happening because by user tasks are linked to forms and, in the BPMN diagram, they don’t have inputs or outputs defined.

What do you all think is happening?

EDIT: Escaping does not help, and with certain values, the next error appears. To me, my input looks valid according to what the error message says, but I could be missing something.


1 Like

Hello my bro!

Do you want to share your process model with us?
Are you using any DMN?

Is this “aprobada” a checkbox in your user task?

William Robert Alves

Hello! How are you?

Of course! This is the BPMN diagram. As you can see, I’m only using tasks.

And no, “aprobada” is a radio element.

Everythings ok bro o/ And you? How’s things?
:smiley:

Let me ask, why are you using “Radius” and not “Checkbox”?

Wouldn’t it be a better practice to have a checkbox to mark “Aprobada” and when checked it returns “true”, and when unchecked it returns false?

William Robert Alves

1 Like

Everythings great! Thanks for asking!

I was using a radius element because, to me, it is more explicit to have those two options. But, thinking about it, a checkbox would be easier to handle. Now, does that cause the bug that I showed earlier? And if so, why?

Hi!

So… JSON String is not a String containing JSON.
It’s a language error somewhere.
Make sure to put all your variable values in "" blocks.

eg.

{
"variables": [
      {
             "name":"decision",
             "value": "\"aprobada\""
      }
   ]
}

or

{
    "variables": [
        {"name": "fechaInicio", "value": "\"10.10.2023\""},
        {"name": "fechaFin", "value": "\"10.11.2023\""},
        {"name": "razon", "value": "[\"vacaciones\"]"}
    ]
}
1 Like

Hi guys, all right?
The problem can also be in the gateway line, if there is no “” in the aprobada, it returns this error as it cant identify it as a string.
Example: ${decision ==aprobada} instead of ${decision == “aprobada”} would cause this error.

2 Likes

That was exactly the problem! Thank you so much @GotnOGuts. Since in the documentation I just saw normal “strings” being used in the value field, I assumed I had to use just normal strings. Reading the original JSON standard (JSON) also helped me make a bit more sense about this.

Thanks again, have a great day!

Hi @Rosana! Thanks for your answer. What you suggest was one of the first things that I checked. I was declaring the value as a string inside of the gateway line.

Now, your answer does leave me with a doubt. I’ve seen some other BPMN diagrams where people use the ${…} format when referring to variables or expressions. As far as I know, Camunda uses FEEL, and that notation is primarly used in template strings in JS. So, am I also writing my expressions wrong?

Camunda 7 uses the ${…} syntax.
Camunda 8 uses FEEL syntax.

For Camunda 8, your condition is expressed in the correct syntax.

1 Like

In Camunda 7 we use ${} to indicate that we are dealing with an expression.
In camunda 8 this is not necessary.

I’m not sure, but I think one of your problems is a single “=” in your validation.
A single = sign indicates value assignment and no verification.

Instead, use ==
Example:

decision == "aprobada";

William Robert Alves

1 Like

As far as I know, in FEEL, the boolean expressions use only one equal sign, as seen here: Boolean expressions | Camunda Platform 8 Docs



1 Like

Got it! Thanks again!

If your issue is resolved, please mark one of the comments as the solution to help others that might be running into the same issue.

1 Like

Done! Have a great day!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.