Loading TOC...

xdmp:get-request-body

xdmp:get-request-body(
   [$format as xs:string?]
) as item()*

Summary

For PUT or DELETE requests, returns the body of the request. For POST requests, returns the body of the request if it is not of content-type application/x-www-form-urlencoded.

Returns the empty sequence if it is not called from an application server.

Parameters
format The format ("xml", "json", "text", or "binary") to interpret the body as. If not supplied, the format associated with the content-type header in mimetypes.xml is used. If no content-type header exists, the default format is "binary".

Usage Notes

If the content-type of the POST body is application/x-www-form-urlencoded, it is not available here, but instead is available in its decoded form through xdmp:get-request-field-names() and xdmp:get-request-field().

If there is no content-type header in the request, then the request body defaults to application/x-www-form-urlencoded, and therefore xdmp:get-request-body will return the empty sequence. If you want to read the request body, then the POST must include a content-type header.

You can use this function to process certain types of web service SOAP requests with MarkLogic Server.

The output of an xdmp:get-request-body call is typically a document node, so if you want to get the contents of the POST, you should add a /node() XPath step to the output. The contents of the document node could be a text node, an element node, or a binary node.

Example

xdmp:get-request-body()/node()
=> "<a>Contents of POST body.</a>"

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.