Make Selenium Easy

Postman Tutorial Part 52 – How To Send Parameterized XML Payload In Postman

As a part of Postman Tutorial – End to End , in this post, we will learn how can we send a XML payload and parameterized XML payload to request in Postman.

We can pass payload to a request in multiple ways. Sending XML payload is one of them. We also learnt how can we send a JSON and JSON with variables i.e. Parameterized JSON payload to a request.

Example API for Demo :-

We will be going to use RestFul-Booker Create Booking API for Demo. Create Booking API accepts JSON and XML payloads. We will create a booking by passing XML payload in Postman.

We can see header details and example request body in API documentation:-

Note :- We need to pass a header named “Content-Type” as “text/xml“. It is not supporting “application/xml“. In all latest APIs , you will see ” application/xml “. ” text/xml ” is superior of ” application/xml “.

Let’s start :-

Pass Create Booking API to URI section and add “Context-Type” header in Postman :-

Pass request body as XML :-

Click on Send button, and you will see a booking created.

So above are simple steps to pass a XML payload to request.

You can see we have passed all hard coded values in payload which is not always a good option. We can parameterized XML payload to pass values dynamically and achieve data driven as well.

Passing variables in XML payalod is same as we use variables at different places in Postman i.e. {{variableName}}. Let’s see this in action.

I will create an environment “Data Booking” in Postman and put all required values there and will use those variables in payload.

Let’s put variable names in XML payload as below:-

Select created environment file and hit “Send” key:-

Simple. It is similar to passing variables in JSON payload.

If you would like to see response in XML, set a header named “Accept” and set it as “application/xml”.

Hit the Send button and by default you will see response in XML :-

We will see extracting values from XML response in upcoming posts.

You can import example collection from here.

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
#ThanksForReading
#HappyLearning

You can find all Selenium related post here.
You can find all API manual and automation related posts here.
You can find frequently asked Java Programs here.

Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

Leave a Reply

Please wait...

Subscribe to new posts to become automation expert

Want to be notified when my new post is published? Get my posts in your inbox.

Postman Tutorial Part 52 – How To Send Parameterized XML Payload In Postman

by Amod Mahajan time to read: 2 min
0
%d bloggers like this: