How to log the request received by WebApi's if it is exposed for third party system to consume?

Hi,

 

We have Webapi's which are exposed to third party system to consume, I would like to know how to enable logs to know the request/response details which has been received/sent whenever the webapi is invoked by the third party system.

We are calling Expression Rules from our Webapi and not triggering any processes.

 

 

Regards,

Balaji.R

  Discussion posts and replies are publicly visible

  • Hi Balaji.R,

    We have write to DB function available (a!writeToDataStoreEntity) to create an entry to DB on Interface or Web API. You can call this function before and after calling your web API body function to write Request & Response respectively.

    From DB perspective, you can create an audit structure table which can store both Request and response data.

    Regards,
    Simple Shah
  • 0
    A Score Level 1
    in reply to simples533
    Hi Shah,

    Thanks for your response, I understand the request/response can be logged in DB through necessary coding inside Webapi but I would like to understand if there is anyway that we can enable the DEBUG log for Webapi's, so it will start logging the request/response for all the webapi's available.

    Regards,
    Balaji.R
  • Hi Balaji,

    I did not come across this but, I have one work around for this. We can write one custom plugin which intern will log the request and response to some log file. Code will be like the plain java code with custom logger.

    Hope this may help.
  • 0
    A Score Level 1
    in reply to Shanmukha
    Hi Shanmukha,

    Thanks for your response, and I never been part of Plug-in creation, so if possible can you give me some insights on Plug-in creation which may serve the logging purpose.


    Regards,
    Balaji.R
  • 0
    A Score Level 1
    in reply to rp_balaji
    Hi Balaji,
    You can get this basic info from forum itself. I have created all the plug-ins based on that. Cmg to logging then you have to follow basic logger mechanism like Java.

    Let me know if you need more info.
  • Hi Balaji -

    You certainly can investigate building a plugin for this.

    I personally would recommend that you consider using an approach similar to what  proposed, though.

    Using the database to track the transactions that reach Appian is easy to set up and reliable.

    Longer term maintenance of this utility is going to be easier in the database than maintaining a plugin as well.

    Also, you said you want to "enable logs to know the request/response details which has been received/sent whenever the webapi"

    That's a lot of data to manage in log files.  These could grow very large, and we don't know how well your plugin is going to manage generating all those logs.  I suspect you wish to avoid doing anything that will slow down your system.

    Consider looking for a way to log all of this at the network layer, outside of Appian.

  • 0
    A Score Level 1
    in reply to Shanmukha
    Hi Shanmukha,

    Thanks for your suggestion, will explore much on plugins for logging to log files.

    Regards,
    Balaji.R
  • Hi Rob,

    Thanks for your response, i am also with you by choosing the option of logging the data in to database but I would like to explore on the options of writing plugins to log the request/response data into log files.

    And regarding the point about data management in log files for logging each request and response, I am thinking of an approach of using flags (which will be stored in constants) to decide when to log and when not to log data. In that way I think we can restrict every request/response getting logged in the log file.

    I would like to seek you suggestion in terms of performance on the mentioned approaches, i.e., 1) writing data into Appian DB or 2) writing data outside Appian (either in DB or filesystem) or 3) writing request/response into Appian log files only on demand. Among the three approaches please let me know which one would be a better approach in terms of performance.

    Regards,
    Balaji.R
  • 0
    Certified Lead Developer
    Hi

    Adding to the suggestions provided by the practitioners.

    If you are only looking to debug the Request and Response then,

    Why don't you create and configure an Integration Object having the same service account details (provided to Third Party) configured and try invoking the Web-API to understand the Request and Response sent/received via this API. As you are aware that Integration Object acts like a Consumer and can consume an exposed Web Service (with-in or outside Appian Environment).

    Alternatively you can use other Third-party clients such as SOAP UI to understand the Request and Response Data and their format.

    NOTE: This approach is only applicable for Testing and debugging an API. And if these clients are able to consume and get the Response from your API then your Third Party Client should also be able to get the response as expected (if the configurations in the Client side are provided properly)