Postman Complete Task from API

I am trying to complete a task with Postman. I can find the task with a GET without any problem.

localhost:7070/engine-rest/task/12658

However, when I try to use POST using
localhost:7070/engine-rest/task/12658/complete

I get the error below. What am I missing?

"type": "NotSupportedException", "message": "RESTEASY003065: Cannot consume content type"

Please try this

curl --location --request POST ‘http://localhost:8080/engine-rest/task/72a40835-11fe-11eb-ae7f-0050568563f4/complete
–header ‘Accept: application/json’
–header ‘Content-Type: application/json’
–data-raw '{

“variables”:
{
“name”: { “value” : “Prasad” },
“pin”: { “value” : “91818282” }
}
}’

I forgot to mention that I am using port 7070 for Camunda. I didn’t realize about setting the headers.

Thanks it worked!

How can I do the same thing in a Java call?

do you want to make the call from within the Process application or outside. If it is outside you have to use a java rest client. If it is from process application refer

Thanks for your help I looked at Completing a User task with Java API
but I am new to Java and don’t quite understand everything yet. Below is what I have tried so far and am getting

No signature of method: org.camunda.bpm.engine.impl.ProcessEngineImpl.call() is applicable for argument types: () values: []

def varNames = runtimeService.getVariables(it.executionId)
String requestId = varNames.requestId
String pidm = varNames.pidm
String taskId = ‘a76bb7f7-1220-11eb-b309-0800271e8913’
if (requestId != null && pidm != null) {
def advisorApprovalCheck = approvalMySqlService.advisorApprovalCheck(requestId, pidm)
if(advisorApprovalCheck != null) {
def advisorComplete = processEngine()
.setVariable (“advisorApproval”, advisorApprovalCheck.advisorDecision)
.complete(taskId)
}
}

Here is the corresponding Java code… Hope this helps…

Map<String, Object> varNames =
getProcessEngineServices().getRuntimeService().getVariables(executionId);
Object requestId = varNames.get("requestId ");
Object pidm = varNames.get(“pidm”);
String taskId = “a76bb7f7-1220-11eb-b309-0800271e8913”;
if (requestId != null && pidm != null) {
advisorApprovalCheck = approvalMySqlService.advisorApprovalCheck(requestId, pidm);
if(advisorApprovalCheck != null) {
Map<String, Object> variables = new HashMap<String,Object>();
variables.put(“advisorApproval”, advisorApprovalCheck.advisorDecision);
getProcessEngine().getTaskService().complete(taskId, variables );
}}

Thanks for your help!

I am actually using Groovy for this project. I was able to use your code to get a better understanding of what I needed to do. However, I am stuck trying to figure out how to get the task value to put into the .complete. Here is what I currently have.

  def activeTasks = processEngine
            .getTaskService()
            .createTaskQuery()
            .active()
            .list()


//println(activeTasks)

    activeTasks.each {
        Map<String, Object> varNames =
                getProcessEngine().getRuntimeService().getVariables(it.executionId);
        String requestId = varNames.requestId
        String pidm = varNames.pidm
        String taskId = activeTasks
        //           String taskId = activeTasks.Task
        println(taskId)
        if (requestId != null && pidm != null) {
            String advisorApprovalCheck = approvalMySqlService.advisorApprovalCheck(requestId, pidm);
           println(advisorApprovalCheck)
            if(advisorApprovalCheck != null) {
                Map<String, Object> variables = new HashMap<String,Object>()
                variables.put("advisorApproval", advisorApprovalCheck)
                getProcessEngine().getTaskService().complete(taskId, variables)
            }}

I get the error "Cannot find task with id [Task[a85ba969-12d7-11eb-822d-0800271e8913]]: task is null " How do I only get the task id number and not the variable name? I tried using activeTasks.Task but it didn’t recognize that variable.

activeTasks is a list of active tasks. So you need to iterate it and pass one by one to the complete method.

Thanks, I am iterating through the activeTasks now. However, when I run my process I get

org.camunda.bpm.engine.ProcessEngineException: condition expression returns non-Boolean: result has class java.lang.String and not java.lang.Boolean

Below is my code:

Map<String, Object> variables = new HashMap<String,Object>()
                variables.put("advisorApproval",  advisorApproval.advisorDecision)
                getProcessEngine().getTaskService().complete(it.id, variables)

the variable that I am adding to each task is a string not a boolean.

I found the solution. In my model the condition expression had an extra } on the end of it.

Thanks again prasadps for all of your help!