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 Reply Children
  • Responding to an old thread as I ran in to a problem related to this.

    I have a Web API that accepts JSON request with few attributes. One of the attribute in the request is in JSON format and I ran in to issue while passing this value to process model. Below is the request format.

    "payload" attribute is mapped to a text variable in process model but the variable value is in dictionary format and not able to retrive each values from this variable (like Attribute2_2_1) in the process model.

    Is a there way I can retain the JSON format in process model variable ? I have already tried converting this to a JSON using a!toJson/a!fromJson but unable to convert the format. Thank you.


    {
    "Request":
    {
    "Attribute1":"value",
    "payload":
    {
    "Attribute2_1":"value",
    "Attribute2_2":
    {
    "Attribute2_2_1":"value",
    "Attribute2_2_2":"value"
    },
    "Attribute3":"value"
    }
    }
    }

    Value in Payload variable on Process Model:

    [payload:[Attribute2_1:value, Attribute2_2:[Attribute2_2_1:value, Attribute2_2_2:value], Attribute3:value]]
  • Hello,

    Did you find a way to have the format correctly in variable?

  • It isn't possible to create process variable of "Dictionary" or "Any Type", so your best bet is to create a custom data type that matches the structure of this JSON request. Then, create a variable using that CDT and it will preserve the structure in your process variable.

  • Yes. Extracted the values from the request and assigned to Process parameter. This way you can get the actual request in JSON format in to the process model. Sample below.

    Request :

    {
    "Request":
    {
    "Attribute1":"value",
    "payload":
    {
    "Attribute2_1":"value",
    "Attribute2_2":
    {
    "Attribute2_2_1":"value",
    "Attribute2_2_2":"value"
    },
    "Attribute3":"value"
    }
    }
    }

    WebAPI:

    a!startProcess(

             processModel:cons!PM_NAME,

            processParameters:

             {

                       Attribute1:a!fromJson(http!request.body).Request.Attribute1,

                       payload:a!toJson(a!fromJson(http!request.body).Request.payload)

              }

    )