<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/xdmp.httpPost.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>xdmp.httpPost</api:function-name><api:suggest>xdmp.httppost</api:suggest><api:suggest>xdmp</api:suggest><api:suggest>httppost</api:suggest><api:function-link mode="xquery" fullname="xdmp:http-post">/apidoc/8.0/xdmp:http-post.xml</api:function-link><api:function mode="javascript" name="httpPost" type="builtin" lib="xdmp" category="Extension" subcategory="HTTP" hidden="false" bucket="MarkLogic Built-In Functions" prefix="xdmp" namespace="http://marklogic.com/xdmp" fullname="xdmp.httpPost"><api:summary>
  Sends the http POST request to the server.
</api:summary><api:params><api:param name="uri" type="xs:string" optional="false"><api:param-description>
  The URI to which the data is to be posted.
  </api:param-description><api:param-name>uri</api:param-name><api:param-type>String</api:param-type></api:param><api:param name="options" type="(element()|map:map)?" optional="true"><api:param-description>
    
    <span class="javascript" xmlns="http://www.w3.org/1999/xhtml">The options object for this request.
    The default value is null.</span>
    
    <p class="javascript" xmlns="http://www.w3.org/1999/xhtml">The <code>xdmp.httpPost</code> options include
    the following option, in addition to the options documented with the
    <a href="./xdmp.httpGet"><code>xdmp.httpGet</code></a> $options parameter:</p>
    <blockquote xmlns="http://www.w3.org/1999/xhtml"><dl>
    
    <dt class="javascript"><p>data</p></dt>
    <dd>This option can contain any string. Anything in the <code>data</code>
    option is sent as a string in the PUT or POST body. When POSTing to a web
    service, the data may need to be a SOAP XML structure or binary content.
    The optional third argument can be used to specify the body instead.
    </dd>
    <dt><p>The other options are the same as the other
    <code class="javascript">xdmp.http*</code>
    functions, and the options are documented with the
    
    <a class="javascript" href="./xdmp.httpGet"><code>xdmp.httpGet</code></a>
    $options parameter.</p></dt>
    </dl></blockquote>
  </api:param-description><api:param-name>options</api:param-name><api:param-type>Object?</api:param-type></api:param><api:param name="data" type="node()?" optional="true"><api:param-description>
    The data for this request. This is an alternative to the
    <code xmlns="http://www.w3.org/1999/xhtml">data</code> option for the second parameter that allows binary
    content to be specified for the body of the POST.
  </api:param-description><api:param-name>data</api:param-name><api:param-type>Node?</api:param-type></api:param></api:params><api:return>ValueIterator</api:return><api:usage>
   <p xmlns="http://www.w3.org/1999/xhtml">The http functions only operate on URIs that use the http or https
   schemes; specifying a URI that does not begin with <code>http://</code>
   or <code>https://</code> throws an exception.</p>
   <p xmlns="http://www.w3.org/1999/xhtml">If an http function times out, it throws a socket received
   exception (SVC-SOCRECV).</p>
   <p xmlns="http://www.w3.org/1999/xhtml">If you expect the request body from this http function to be
   processed by another application (via a web service, for example),
   you should specify a content-type header. If no content-type header is
   specified, the content type defaults to text/plain.</p>
</api:usage><api:privilege>
   <code xmlns="http://www.w3.org/1999/xhtml">http://marklogic.com/xdmp/privileges/xdmp-http-post</code>
</api:privilege><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
xdmp.httpPost("http://www.my.com/document.xhtml",
     {
       "authentication" : {
         "method" : "basic",
         "username" : "myname",
         "password" : "mypassword"
       }
     });
=&gt; the response from the server as well as the specified document

</pre></api:example><api:example class="javascript"><a id="http-data-payload" xmlns="http://www.w3.org/1999/xhtml"></a><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
//  Use xdmp.quote to encode the JSON as a string
//  because the "data" option is a string 

var payload = xdmp.quote({"foo":"bar"})
xdmp.httpPost("http://www.my.com/document.xhtml",
     {
       "authentication" : {
          "method" : "basic",
          "username" : "myname",
          "password" : "mypassword"
       },
       "data" : payload,
       "headers" : {
         "content-type" : "application/xml"
       }
     });
=&gt; the response from the server as well as the specified document

</pre></api:example></api:function></api:function-page>