Status code of a webapi to start process model

Hi, 

I have a webapi created in appian that starts a process model, it always returns a 200 status code because starting the process correctly, but this process can fail.

Is there any way that this webapi does not return statusCode 200 if the process fails at some point?

Thanks

  Discussion posts and replies are publicly visible

Parents
  • If you used the template for starting a process model via webapi you'll see that the onSuccess parameter is evaluated when the process kicks off successfully. However, the onSuccess also won't evaluate until the chain completes within a process. What this allows you to do is chain a number of nodes together starting with the beginning of your process model and at certain points update a process variable with the progress. Then using the function variable fv!processInfo you'll be able to use the values of these process variables in the onSuccess parameter. Documentation is here https://docs.appian.com/suite/help/20.4/Start_Process_Smart_Service.html#a!startprocess(). Using those variables you can return different status codes.

    Please remember that by chaining your process this will cause Appian to prioritize executing those nodes. Also, if you have a lot of nodes this means your webapi request time will be slower.

    Does this help?

    a!startProcess(
      processModel: cons!PROCESS_MODEL,
      processParameters: a!fromJson(
        http!request.body
      ),
      onSuccess: {
        if(
            fv!processInfo.pv.finishedAllNodes,
            a!httpResponse(
                statusCode: 200,
                headers: {
                  a!httpHeader(name: "Content-Type", value: "application/json")
                },
                body: a!toJson(
                  fv!processInfo
                )
             ),
             a!httpResponse(
                statusCode: 205,
                headers: {
                  a!httpHeader(name: "Content-Type", value: "application/json")
                },
                body: a!toJson(
                  {
                    error: "Process started but not all nodes completed successfully"
                  }
                )
              )
        )
      },
      onError: a!httpResponse(
        statusCode: 500,
        headers: {
          a!httpHeader(name: "Content-Type", value: "application/json")
        },
        body: a!toJson(
          {
            error: "There was an error starting the process"
          }
        )
      )
    )

  • Hi,

    I've tried with activity chaining but it seems that calling subprocesses or assigning tasks break that chain and sends the response right away. In this case, how can i delay the response until the process ends?
    Thanks.
  • 0
    Appian Employee
    in reply to salehc0001

    Here are the docs for breaking a chain https://docs.appian.com/suite/help/17.4/Configuring_Activity-Chaining.html#breaking-a-chain

    You are able to chain into a sub-process as long as all the nodes you need are also chained and you set the correct settings on the sub-process node. A user task is expected because a user could sit on that task for days which means your REST call would time out well before that.

    If these still don't meet your use case, you might want to look into setting up some kind of callback where Appian can call your service after the process completes.

Reply Children