Skip to content

Commit

Permalink
Explain how to send xml request from script
Browse files Browse the repository at this point in the history
  • Loading branch information
vdespa committed Sep 28, 2019
1 parent d885d70 commit f23a53a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# The short X.Y version
version = u''
# The full version, including alpha/beta/rc tags
release = u'Version 1.3.2 - September 2019'
release = u'Version 1.3.3 - September 2019'


# -- General configuration ---------------------------------------------------
Expand Down
33 changes: 33 additions & 0 deletions docs/request-creation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,39 @@ Below I am fetching a name from a remote API and setting it as a variable for us

You can import this example in Postman by using this link: https://www.getpostman.com/collections/5a61c265d4a7bbd8b303

How to send request with XML body from a script?
------------------------------------------------

You can use the following template to send a XML request from a script. Notice that `price` is a Postman variable that will be replaced. ::

const xmlBody = `<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>{{price}}</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
</catalog>`;

const options = {
'method': 'POST',
'url': 'httpbin.org/post',
'header': {
'Content-Type': 'application/xml'
},
body: pm.variables.replaceIn(xmlBody) // replace any Postman variables
}


pm.sendRequest(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});


How to pass arrays and objects between requests?
------------------------------------------------
Expand Down

0 comments on commit f23a53a

Please sign in to comment.