Vijay Akula Thanks for sharing the additional details. I have tested the sample policy snippet you shared with echo endpoint [http://echoapi.cloudapp.net/api/resource] and didn't produce any issue. Here are the details:
Output:
Code snippet:
<outbound>
<set-variable name="response-body" value="@(context.Response.Body.As<string>(preserveContent: true))" />
<set-body template="liquid">{
"error": {
"code": "{{body.envelope.body.someResponse.SomeName}}"
}
}</set-body>
<base />
</outbound>
Request info:
I understand you may not be able to share the full sample request, response or exact policy info. Make sure to validate the casing such as fault, faultcode in the actual response.
If you still need help, we can connect offline and send an email to azcommunity@microsoft.com referencing this thread with your subscription ID, details and subject as "Attn: Muthu". I will assist you with next steps.