Complete User Task with REST API

Hi Camunda Team, I am currently studying Camunda and trying to adapting it.

  • Here is the use case:
    1. Employee Requests Update Product Price.
    1. Manager get notified to Review Request.
    1. Manager Approve/Reject the request.
    1. Employee get notified the Approval/Rejection.
    1. Product Price being updated.

I would like to use REST api to do step 3 [Manager Approve/Reject the request] which should be apply to Complete Task API with request body:

{
  "variables": [
    {
      "name": "decision",
      "value": "approved"
    }
  ]
}

since the Review Request Form was designed to have a radio group called “decision” with options “approved” and ''rejected".

but currently I will receive the error like:

{
    "status": 500,
    "message": "Unrecognized token 'approved': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 9]",
    "instance": null
}

How can I use API with the request body to make the approval/ rejection? Thanks

Hey,

Welcome to the forum.
As the error message indicates, you need to provide a JSON String rather than a String.

Try using

{
  "variables": [
    {
      "name": "decision",
      "value": "\"approved\""
    }
  ]
}
2 Likes

Hi @GotnOGuts Thank you so much! It works for me now.

Hi @cody_huang,

Be informed that for zeebe user tasks, the variable’s value is provided as is. (String as String, JSON as JSON and so on)

2 Likes

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