Postman 1749470438
Postman 1749470438
y
of software should communicate with another.
● API serves as a connection point between two software applications, allowing
m
them to communicate. A programming interface (API) is a set of software
capabilities that another application can use.
de
● It can be considered as the waiter which acts as the middleman between your
requests and the chef. Similarly API refers as the middleman between a client
and a server.
● Postman
● SoapUI
● Katalon Studio
● Tricentis Tosca
● Apigee
● Jmeter
3) What is Postman?
● Postman is an API platform for developers to design, build, test and iterate their
APIs.
● We can say Postman is an API platform for building and using APIs.
● Postman is an API (application programming interface) development tool which helps
to build, test and modify APIs. Almost any functionality that could be needed by any
developer is encapsulated in this tool.
● It is used by over 5 million developers every month to make their API development
easy and simple.
Shyam Kumar
EmailId:- [email protected]
Consider Below example - Restful Booker is a collection where we have full CRUD
requests present.
● It is free: Postman is free software that we can use for API testing. It is free to
e
download it, and we can send our first request in minutes. It also gives us the
ability to save environments for future use.
● Community & Support: It has a huge community forum for customer support
and extensive documentation.
● APIs Support: It facilitates us to make any API call (REST, SOAP, or plain
HTTP) and easily inspect even the largest responses. It also helps manage
the end-to-end lifecycle of the API - starting from design to mocking to testing
and finally maintaining the APIs.
y
preferred CI/CD tools and services, such as Jenkins with Newman
m
(command-line collection runner).
13) Can we have the same names for global variables in postman?
A:- The scope of global variables is limited to the workspace and is global. Due to this,
variables having global scope cannot have the same names. We can have the same names
for local variables but they need to be part of different variables.
working of collection runners. They run every request in the collection and analyze the
values mentioned in the test scripts. Monitors use the test scripts for validating and
monitoring the responses. The reports generated are shared with the developers over emails
or alerts in slack, hipchat, etc based on our configuration settings.
17) How can you save the responses of API to a file in Postman?
A:- We can do this in two ways:
● :- Click on the Download button in the response section.
● :- Click on the arrow beside the send button - There will be an option to send and
download. Clicking on it will prompt Postman to ask the location of saving the
response post successful execution of the request.
Shyam Kumar
EmailId:- [email protected]
32) Can you have two global scope variables with the same name in Postman?
A:- No, the global scope never has duplicate/same names, while variables having local
scope can have the same name in various environments.
35) Why is saving your work in the Postman cloud is not advisable?
A:- You should not save your work in Postman as your business details do not remain
confidential. Moreover, saving your on-Postman cloud may cause a security breach as it
requires sign-in. Therefore, saving your work in the Postman cloud is not advisable.
41) What test code allows you to check whether the response status is 200 or
not?
A:- Following is a test code to check whether the response status is 200 or not: tests[“Status
Code is 200”] = responseCode.code === 200;
42) Describe any four response things you receive from a response (Correct or
Incorrect)
A:- Status Code
● Response Status
● Response time
● Response Size
● Response Headers
● Response Cookies
● Response Date and Time
● Response Session limit
● Response Cookies
● Response Server
● Response type
Shyam Kumar
EmailId:- [email protected]
A:- You can iterate a request 100 times in Postman by using Collection Runner.
44) Can you read the Postman Chrome application to read and write cookies?
A:- No, it is impossible to read and write cookies using the app.
47) What are the different types by which we can see the response body in
Postman? Explain.
In Postman, a response body can be seen by three different types.
● Pretty
● Raw
● Preview
Although all the three have their own importance and value in Postman, the most
commonly used is Pretty as it shows the response code in different format and colors
which is easy to read and analyze the response. It is just like any good text editor
used for coding
50) Which method should you prefer? Javascript or Functional to write the
tests?
A:- It is advised and recommended to use the functional method while writing tests in
Postman. Although there has been no notice of ending the support for JS method.
A simple code written in the chai library which tests if number 3 is already in the
array or not.
a
1. Realm - A string specified by the server in the WWW-Authenticate response
header.
g
response header.
3. Algorithm - A string that indicates a pair of algorithms used to produce the
digest and a checksum. Postman supports MD5 and SHA algorithms.
es
4. qop - The quality of protection applied to the message. The value must be
one of the options specified by the server in the WWW-Authenticate
eT
response header.
5. Nonce Count - The hexadecimal count of the number of requests (including
Th
the current request) that the client has sent with the nonce value in this
request.
6. Client Nonce - An opaque quoted string value provided by the client, used by
both client and server to avoid chosen plaintext attacks, to provide mutual
authentication, and to provide some message integrity protection.
7. Opaque - A string of data specified by the server in the WWW-Authenticate
response header, which will be used unchanged with URIs in the same
protection space.
Shyam Kumar
EmailId:- [email protected]
y
m
de
ca
2) In a Collection Run, what will execute first?
A:- In a Collection run, pre-request scripts at the Collection level are executed first.
gA
3) What is "x-www-urlencoded" in the Post method in Postman?
A:- Form data and x-www-form-urlencoded are very similar. They both are used for
ti n
almost the same purposes. But the difference between the form data and
x-www-form-urlencoded is that the url will be encoded when sent through
es
A:- Newman is used with Postman normally as a command line interface to serve
continuous integration.
Shyam Kumar
EmailId:- [email protected]
A:- In Newman it is not necessary to run the complete collection to check just a
bunch of requests. This is obviously time consuming and not recommended. We can
also run just a folder located inside a collection in the Newman. For running a folder
in Newman, the following command is used
y
6) How can Postman collections run through the command line?
m
Answer: Postman has a command-line integration tool called Newman with which you
can run any existing Postman collection.
de
Newman is a node js based package, which requires just a node environment to execute
ca
the collection and has full parity with the Postman collection runner i.e. the Newman
collection runner supports the Postman capabilities like Running assertions, Pre-request
A
scripts or any other scripts that are associated with the requests that are a part of the
collection.
ng
To use Newman:
7) How can you generate HTML based reports running tests through the
Postman?
Answer: Newman uses the concept of reporters and templates to generate HTML
reports for the executed collection.
Hence, to generate HTML reports, you first need to install a reporter. You can install any
of the available HTML reporters like Newman-reporter-html as a node package through
y
the below command.
Once the HTML reporter is installed, we can use the Newman command to run the
collection with -r flag i.e. the reporter flag and specify the reporter name as HTML.
Please note that as we have not mentioned the name or folder where we want the
reports to get generated, by default the reports will be generated in a folder named
in
“Newman” that gets created in the same directory where the Newman command is
executed from.
9) Why does Postman never accept any other encoding apart from Base64?
A:- You can use base64 as it helps us transmit the data into the textual form and send it as
HTML form data. Moreover, we must rely upon the same 64 characters in any encoding
language.
e
Collection with the auth token to the Collection. By choosing "Inherit auth from
parent" under the Authorization tab, we may apply it to each request separately.
A:- For all the requests in a collection, the scripts will execute in the following given
order:
eT
Step 1) A pre-request script associated with a collection will run before every
request.
Th
Step 2) A pre-request script associated with a folder will run before every request in
a specific folder.
Step 3) A test script associated with a collection will run after every request.
Step 4) A test script associated with a folder will run after the request in the specific
folder.
Shyam Kumar
EmailId:- [email protected]
The equivalent 200 OK response would have included the headers Cache-Control,
y
Content-Location, Date, ETag, Expires, and Vary.
em
In Detail Answer to above Question.
A:- An HTTP status code is a response code sent between a browser and a web
server every time the browser receives an HTTP request. For example, when you
enter a URL to access a website.
When you make a request on your browser, it will send an If-Modified-Since request
header to the web server. This request header is sent to know when the web page in
question was last modified.
Then, the Last-Modified response header will specify when the web source was last
modified. If there’s no change, the server will send the HTTP 304 response code.
The HTTP status code 304 means Not Modified – the web page you requested
hasn’t changed since the last time you accessed it.
After that, your browser will retrieve the cached version of the web page in your local
storage. That way, the browser doesn’t have to download the same information from
the website’s server repeatedly.
Shyam Kumar
EmailId:- [email protected]
16) How do you write test cases for basic authentication in Postman?
A:- Basic Authentication is one of the authentication techniques provided in Postman
that ensures that we can set the username and password along with the API
requests. We can do this by first setting the credentials of the API by:
● Navigating to the Authorization tab.
● From the dropdown, select Basic Auth.
● Add the username and password to the API in the input fields given.
y
pm.test("Is the Request Authenticated?", function () {
m
var jsonData = pm.response.json();
//if authenticated then assert to true
de
pm.expect(jsonData.authenticated).to.eql(true);
});
pm.test("Is the Content-Type present?", function () {
});
ca
pm.response.to.have.header("Content-Type");
● Add the below lines of code in the script to add a request header for all the
eT
18) How will you stop the execution of upcoming requests or Stop execution of the
collections?
A:- We can use the below code to stop the execution of the next request:
pm.setNextRequest(null);
20) How can we use Custom Javascript libraries in our scripts with an example?
A:- Postman provides a lot of built-in tools and libraries that we can use to add in our
pre-request or post-request scripts or test cases. Let us take the example of using
the moment.js library. It provides a lot of useful functions to format data around time.
Consider that we have a POST request that needs to specify the created date to the
de
user which expects the format “DD/MM/YYYY”. We can use the moment library to
perform this using a single line of code. In our pre-request script, we need to add
the below lines of code to get the correctly formatted data and then store that in an
environment variable:
var moment = require('moment');
pm.environment.set('createdDate',moment().format('DD/MM/YYYY'));
There are a lot of other useful libraries like crypto.js that are useful for converting
text to encrypted values which can further be used anywhere in the request body.
21) If we have a global and a local variable of the same name, which one will be given
the most preference in Postman?
A:- In such cases, the higher precedence is given to the local variable by overwriting the
value of the global variable.
● Personal Workspace:
○ These workspaces are useful when we are working simultaneously on
multiple projects and we require logical separation between the
requests to handle the requests better.
Shyam Kumar
EmailId:- [email protected]
● Team Workspace:
○ These are created for team collaboration so that more than one person
can be part of testing requests.
○ We can invite new users to collaborate on our collections by sharing
the email id of the users. Once the invite is accepted, the new users can
start contributing to the workspace by adding or modifying the
requests.
We can create a new workspace by clicking on the Workspace icon and then clicking
y
on “Create New”.
em
We can select our workspace to be personal or team workspace by configuring the
properties in the create window.
Step1
c ad
gA
in
st
Te
Step2
e
Th
Shyam Kumar
EmailId:- [email protected]
y
m
23) Does Postman allow flexibility to make use of the command-line?
de
A:- Postman provides a command-line tool called Newman using which we can run
any Postman collection. It is a NodeJS based package that requires a node
environment for executing collections using Newman Collection Runner. It has full
a
parity with Postman’s Collection Runner i.e it provides support for running
assertions, pre-request scripts, or other request scripts linked with the requests that
Ac
belong to the collection.
We can use Newman by following the below steps:
● Install Node
● Install Newman package using npm command as: npm install -g
i
newman
st
● To run the collection, first export the environment to JSON format in Postman.
Te
Then run the below command for running the collection in Newman:
newman run {{path to collection json}} -e {{path to environment
json}}
Th
24) How will you generate random numbers of a given range in Postman?
A:- Suppose you want to generate numbers between the range 1 to N, then it can be
done in the pre-request script as follows:
pm.globals.set('randomNumber', Math.floor(Math.random() * N));
We can then use this variable in the URL as:{{randomNumber}}
Shyam Kumar
EmailId:- [email protected]
25) How do you get the cURL command based on the details of the REST API
obtained from Postman?
A:- You can use the steps listed below to get the cURL command equivalent: As
y
em
c ad
Step 1 - Click on Code
gA
In response to the REST API request, you will receive the cURL command:
tin
es
eT
Th
By choosing the necessary choice from the drop-down, as shown in the image below,
we can also obtain the command for the request in several languages, such as C#,
Javascript, NodeJs, PHP, etc.
Shyam Kumar
EmailId:- [email protected]
y
m
de
ca Step 3 - Select Language
gA
26) How to Find a specific Booking id From the array.
A :
tin
es
eT
Th
Shyam Kumar
EmailId:- [email protected]
y
m
Here is the code
de
pm.test("Find The User ID", function () {
ca
var jsonData = pm.response.json();
gA
for (var i = 0; i < jsonData.length; i++) {
if(counter==1980){
s
}
e
}
Th
});
Shyam Kumar
EmailId:- [email protected]
y
m
de
ca
gA
tin
es
eT
Th
Shyam Kumar
EmailId:- [email protected]
pm.expect(pm.response.text()).to.include("Breakfast");
});
28) How to pass User id, First name, Last Name in the API URL?
y
m
A:- https://restful-booker.herokuapp.com/booking?firstname=Jim&lastname=Smith
de
:-https://restful-booker.herokuapp.com/booking/1112
:-https://restful-booker.herokuapp.com/booking?checkin=2018-01-01&checkout=2019-01-01
ca
29) How to Create Booking Without inserting data in the
parameters in postman
gA
y
m
de
ca
gA
Here is the code
pm.expect(pm.response.text()).to.include("first name is
es
required");
});
eT
Th
Shyam Kumar
EmailId:- [email protected]
A:- in the below image you can see that we passed the space in
the First name, last name and other parameters. And in 2nd
image we’re checking the validation in the Test section.
y
m
de
ca
gA
tin
es
eT
Th
Shyam Kumar
EmailId:- [email protected]
A:- We can pass the token in the Header, in the URL Using the
params and From the Authorization section using the Oath/Outh
2.0
y
m
de
ca
gA
tin
y
m
de
ca
gA
tin
es
eT
Th
32) How to verify the expected and actual Name is the same in
the postman test?
A:- as per the 1st image we created the Booking that Contains
First name as “TheTestingAcademy”.
Shyam Kumar
EmailId:- [email protected]
y
em
ad
As per the below image we’re verifying that after creating the
Booking the First Name is “TheTestingAcademy” or
g Ac
tin
es
eT
Th
Shyam Kumar
EmailId:- [email protected]