How could I send a xdmp:http-post() request that has a x-www-form-urlencoded request body with two key value pairs?
Example request:
let $request-body := <key-value-pairs>
<foo>bar</foo>
<bar>foo</bar>
<key-value-pairs>
return
xdmp:http-post("https://myendpoint.com",
<options xmlns="xdmp:http">
<headers>
<Content-type>application/x-www-form-urlencoded</Content-type>
</headers>
<data>{$request-body}</data>
</options>)
This is unfortunately not in the MarkLogic documentation: https://docs.marklogic.com/xdmp:http-post
This should work:
let $request-body := "foo=bar&bar=foo"
return xdmp:http-post("https://myendpoint.com",
<options xmlns="xdmp:http">
<headers>
<Content-Type>application/x-www-form-urlencoded</Content-Type>
</headers>
<data>{$request-body}</data>
</options>)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments