Logging the original request in the PostClientFlow Response flow when using a target endpoint

Not applicable

I would like to log the original request that was submitted as well as the response sent back using the OOB logging policy as one log policy step within the Proxy Endpoint PostClientFlow Response flow. As part of the processing within my API, I have a target endpoint that I invoke to retrieve some data. As soon as the target endpoint flow starts, the original request is replaced with the request to the target endpoint (i.e. the values in the request.content variable) and I am unable to locate a variable that contains the original request. I tried using an Assign Message Policy on the Proxy Endpoint Request flow to keep the original request but it doesn't seem to be available from the PostClientFlow Response flow. Is there a way to log both the original request and outgoing response in the PostClientFlow Response flow as one logging policy or do I need to log the original request prior to invoking the target endpoint Request flow and then log the outgoing response on the PostClientFlow Response flow?

Solved Solved
0 5 1,935
1 ACCEPTED SOLUTION

Not applicable

Here is what finally provided what I was looking for. I forgot to mention in the original question that I was also looking for the header values. This post was helpful as it indicated to use the Set construct instead of Copy to include the content (for some reason, using <Payload>true</Payload> didn't work for me:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="amp_setOriginalRequest">
    <AssignTo createNew="true" transport="http" type="request">varOriginalRequest</AssignTo>
    <DisplayName>amp_setOriginalRequest</DisplayName>
    <FaultRules/>
    <Properties/>
    <Set>
        <Payload>{request.content}</Payload>
    </Set>
    <Copy>
        <Headers/>
    </Copy>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</AssignMessage>

View solution in original post

5 REPLIES 5

You can use an AssignMessage policy (similar to the below) on Request side to store the original content -

<AssignMessage async="false" continueOnError="false" enabled="true" name="GetFullRequestPayload">
    <DisplayName>originalReq</DisplayName>
    <FaultRules/>
    <Properties/>
    <AssignVariable>
        <Name>originalReq</Name>
        <Value/>
        <Ref>request.content</Ref>
    </AssignVariable>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>

Then you could use "originalReq" variable in the MessageLogging policy in PostClient flow.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MessageLogging async="false" continueOnError="false" enabled="true" name="Message-Logging-1">
    <DisplayName>Message Logging-1</DisplayName>
    <Syslog>
        <Message> The original request content is {originalReq}</Message>
        <Host>IP</Host>
        <Port>556</Port>
    </Syslog>
</MessageLogging>

Hi Sudhee,
Just one more thing, if I want to log both request and response content in one proxy using a Shared Flow, then should I use one more assignmsg policy in the Response Postflow along with this above stated assign massage policy in the Request Preflow and then one massage logging policy in the PostClient Flow to use these two variables and log.

and where can I leaverage the SF onver here ?

Please share your view, I am in confusion as SF would not be able to contain all three (AssnMsg1, AssnMsg2 and MsgLogging) at once.

~Ziaur

Not applicable

Here is what finally provided what I was looking for. I forgot to mention in the original question that I was also looking for the header values. This post was helpful as it indicated to use the Set construct instead of Copy to include the content (for some reason, using <Payload>true</Payload> didn't work for me:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="amp_setOriginalRequest">
    <AssignTo createNew="true" transport="http" type="request">varOriginalRequest</AssignTo>
    <DisplayName>amp_setOriginalRequest</DisplayName>
    <FaultRules/>
    <Properties/>
    <Set>
        <Payload>{request.content}</Payload>
    </Set>
    <Copy>
        <Headers/>
    </Copy>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</AssignMessage>

Not applicable

Can we log both error and info level logs in same policy?

Hi @Shailza.Garg9, I dont think it is possible to have multiple loglevels in same policy. Anyway, create a new post and tell us your requirement.