Making a MarkLogic xdmp:http-post() request with x-www-form-urlencoded request body

Mike J

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

Rob S.

This should work:

let $request-body := "foo=bar&amp;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.

edited at
0

Comments

0 comments
Login to comment

Related

How to send post request with x-www-form-urlencoded body

RestSharp post request - Body with x-www-form-urlencoded values

How to send post request with x-www-form-urlencoded body with loopj-async-http library

PYTHON: requests.post() how to send request_body encoded as application/x-www-form-urlencoded

why can't Volley String request send Body parameters with POST method in x-www-form-urlencoded?

How to sent Http POST request with application/x-www-form-urlencoded

Jersey client Post Request with x-www-form-urlencoded Fails

Spring - wrong encoding POST request with x-www-form-urlencoded

Post a x-www-form-urlencoded request from React Native

Swift 4 send POST request as x-www-form-urlencoded

How to send x-www-form-urlencoded in a post request in webclient?

How is Laravel decoding HTTP request body Content-Type: application/x-www-form-urlencoded when using api call

Why does Axios send my POST request with Content-Type application/x-www-form-urlencoded when using a string as the request body?

Postman and setting up a variable in the body of x-www-form-urlencoded request

Karate DSL: How to add specific key and value (XML) as x-www-form-urlencoded to body of request?

How to do a post request using FORM-DATA or x-www-form-urlencoded with Android?

how to post body x-www-form-urlencoded using webclient?

Node.js Axios POST request with application/x-www-form-urlencoded format?

How to send post request with content-type x-www-form-urlencoded android retrofit

Swift - How to send POST request with "x-www-form-urlencoded" content-type

How test Post request with custom object in content type application/x-www-form-urlencoded?

Postman x-www-form-urlencoded returns null value for a POST request even though the input field is filled

How to send a POST request with Content-Type "application/x-www-form-urlencoded"

Http Put request with content type application/x-www-form-urlencoded not working in Spring

fastify-formbody and fastify-http-proxy are changing application/x-www-form-urlencoded request to string

Request body is empty when making a POST request via HTML form

How do I get raw request body using servicestack with content-type set to application/x-www-form-urlencoded?

How to post request with spring boot web-client for Form data for content type application/x-www-form-urlencoded

my request failed when the post 'content-type' is application/x-www-form-urlencoded and * form field param= { <this is a json object>}