Skip to main content
September 16, 2025
Solved

Why did completeTasks error?

  • September 16, 2025
  • 5 replies
  • 0 views

I am creating a webApi to trigger a!completeTask().  If this encounters an error, I return an httpResponse to indicate such.

The question is:  how do I know what the error was?  Is there some way to return the task completion error in the webApi?

Thank you.

  a!completeTask(
    taskId: ri!taskId,
    taskInputs: {
      someData: "abc",
      moreData: "def"
    },
    onSuccess: a!httpResponse(200, {}, "Success")
    onError: a!httpResponse(500, {}, "What was the error??")
  )

    Best answer by shubhama926776

    Smart services do not expose internal system error details directly in the onError. Custom error messages must be handled by performing validations before calling the smart service. If validation fails, you can return specific error details. You have to rely on logs.

    5 replies

    shubhama926776
    September 17, 2025

    Smart services do not expose internal system error details directly in the onError. Custom error messages must be handled by performing validations before calling the smart service. If validation fails, you can return specific error details. You have to rely on logs.

    September 17, 2025

    I thought that would be the answer.  The most obvious scenario is the task id is wrong.... which we can confirm before calling completeTask....  I wasn't sure what other reason might cause completeTask to fail.

    shubhama926776
    September 17, 2025

    There are couple of scenarios you can pre-validate like, Task Already completed, User lacks permission, required task inputs are missing or invalid, process instance cancelled or terminated and task assigned to different user.

    harshas2775
    September 17, 2025

    You can work with the data the httpResponse sends by matching it with a user friendly message to show to user.

    For detailed errors there is no way to show it directly using the response as that is available within log files. 

    September 17, 2025

    I'm not sure what you mean.  I was looking for reasons why completeTask, itself, might end up calling the onError bit.  If there was some kind of error I could report in the HttpResponse.

    I'm working at the WebApi level here, not the caller of the WebApi.

    Thanks.