Web API to Process model integration

 Hi Folks, 

 

I'm trying to achieve the following:

  • Create WebAPI for JSON request - this Web API accepts a JSON request 
  • After accepting a JSON-type input - a process model is initiated to which this JSON value is passed 
  • If the process initiation is successful, a success response is sent back as acknowledgement 

Any inputs would be great, as I'm just beginning, I can implement more efficient code.  

 

Thanks in advance!!

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi,

    Your web api code should be something like below:

    with(
    a!startProcess(
    processModel: cons!yourProcessModel,
    processParameters: a!fromJson(
    http!request.body
    ),
    onSuccess: a!httpResponse(
    statusCode: 200,
    headers: {
    a!httpHeader(name: "Content-Type", value: "application/json")
    },
    body: a!toJson(
      {"Your Success Message"}
    )
    ),
    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"
    }
    )
    )
    )
    )

Reply
  • 0
    Certified Lead Developer

    Hi,

    Your web api code should be something like below:

    with(
    a!startProcess(
    processModel: cons!yourProcessModel,
    processParameters: a!fromJson(
    http!request.body
    ),
    onSuccess: a!httpResponse(
    statusCode: 200,
    headers: {
    a!httpHeader(name: "Content-Type", value: "application/json")
    },
    body: a!toJson(
      {"Your Success Message"}
    )
    ),
    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"
    }
    )
    )
    )
    )

Children
No Data