Tools, FAQ, Tutorials:
'set-body' Azure API Policy Statement
How to use the "set-body" Policy Statement for an Azure API service operation?
✍: FYIcenter.com
The "set-body" Policy Statement can be used to reset the body of the request
when calling the backend service or the body of the response when returning
response to the client system.
The "set-body" Policy Statement can be used in two ways:
1. <set-body> with no template - You can provide the body text directly or generate text from "@(...)" expressions and "@{...}" expression blocks.
For example, the following "set-body" outbound policy statement uses a "@{...}" expression block to remove a number of properties from response body:
<set-body>@{
var response = context.Response.Body.As<JObject>();
foreach (var key in new [] {"minutely", "hourly", "daily"}) {
response.Property(key).Remove();
}
return response.ToString();
}
</set-body>
2. <set-body template="liquid"> with Liquid Codes - You can provide the body text directly mixed with Liquid codes in "{{...}}" format.
For example, if the following "set-body" inbound policy statement uses a Liquid code to insert the client IP address into the XML document as the request body:
<set-body template="liquid">
<Req>
<Status>New</Status>
<Name>John</Name>
<Age>25</Age>
<ClientIP>{{context.Request.IpAddress}}</ClientIP>
</Req>
</set-body>
Azure will call the backend service with a request body like this:
<Req>
<Status>New</Status>
<Name>John</Name>
<Age>25</Age>
<ClientIP>101.101.101.101</ClientIP>
</Req>
For more information on "set-body" policy statement, see API Management transformation policies Website.
⇒ '{{...}}' Liquid Codes in 'set-body' Policy Statement
⇐ 'xsl-transform' Azure API Policy Statement
2023-02-09, ≈17🔥, 2💬
Popular Posts:
What is EPUB 3.0 Metadata "dcterms:modified" property? EPUB 3.0 Metadata "dcterms:modified" is a req...
How to extend json.JSONEncoder class? I want to encode other Python data types to JSON. If you encod...
What Is session_register() in PHP? session_register() is old function that registers global variable...
How to Instantiate Chaincode on BYFN Channel? You can follow this tutorial to Instantiate Chaincode ...
How to attach console to a Running Container using the "docker container exec" command? I want to ge...