Tools, FAQ, Tutorials:
'context.Request.Body' Request Body
How to access Request body from "context.Request.Body" object in Azure API Policy?
✍: FYIcenter.com
Request body is the HTTP request body, which follows an empty line after request headers.
You can access Request body from "context.Request.Body" object in any policy statements.
This "context.Request.Body" object is of the type, "IMessageBody", which support one method called "As()" as described below:
var body = context.Request.Body.As<T>(preserveContent: bool = false) Where T is string, JObject, JToken, JArray, XNode, XElement, or XDocument.
When executed, As() will parse the request body into the given data type. And the request body will be destroyed, if preserveContent=false.
For example, the following expression block will return the request body with the first character modified as a string without destroy it:
@{
string body = context.Request.Body.As<string>(preserveContent: true);
if (body[0] =='c') {
body[0] = 'm';
}
return body;
}
The following expression block will parse the request body into a Jason object, then return the "Document" property as a Jason string. The request body will destroyed, because the default is "preserveContent: false"
@{
JObject body = context.Request.Body.As<JObject>();
return body.GetValue("Document").ToString();
}
For more information on the built-in "context" object, see API Management policy expressions Website.
⇒ Dump Everything from 'context.Request'
2018-01-24, ≈25🔥, 0💬
Popular Posts:
What Happens If One Row Has Missing Columns? What happens if one row has missing columns? Most brows...
How to add images to my EPUB books Images can be added into book content using the XHTML "img" eleme...
How To Break a File Path Name into Parts in PHP? If you have a file name, and want to get different ...
How to build a PHP script to dump Azure AD 2.0 Authentication Response? If you are use the Azure-AD-...
Tools, FAQ, Tutorials: JSON Validator JSON-XML Converter XML-JSON Converter JSON FAQ/Tutorials Pytho...