Capture Web Api Response as process variable for process exposed as a Web Api

Hi All,

I have a created a Process model which writes data into DB and  this is exposed as Web Api. This Web Api is consumed by external system, which sends data to Appian.

The problem is whenever their is error in data, the Api is throwing 500 error to the external system, but when the process model is monitored, the erroneous data which was sent is getting persisted into DB.

Now, my requirement is to capture the response of the Web Api and use it for DB persistence, like if the response status code of the web api is 200 then the DB persistence will happen else process model has to terminate without any data persistence.

Please suggest me a way to capture the web api response in a process variable.

Thanks in advance,

 

Regards,

Someshwar

  Discussion posts and replies are publicly visible

  • 0
    Certified Associate Developer
    If i'm not mistaking your requirement then you probably need to capture the Web Api response which consists of all the data from external application in the form of web api? If that is the case then you can create a process variable with the data type as text and use that variable in the output Result section of x3 node. In such a way that it will hold the value of Request Response.
  • Hi Vivek,

    Thank you for your reply.
    Can you please elaborate on the solution you are suggesting.

    Regards,
    Someshwar
  • Hi,

    I think your thought might be laborious. Why don't you validate the data before you persist or store the data to DB? So, In the webapi, before you call start process method, validate the input data passed by external system and if the data is correct format, you trigger the function and send respective success or failure response. So, in this approach we are firstly clearing the data format or valid data issues before calling a process. This nullifies the data issues and stores the right data in DB on success note. Even after the valid data format, the process fails which means there is some other valid failure scenarios at the process level or DB level etc.,. so accordingly you can send back failure response to the external system.

    Hope this helps.

    Thanks