Found 75 Articles for REST API

How to write Assertions in Postman with Chai Assertion Library?

Debomita Bhattacharjee
Updated on 03-Aug-2021 13:41:51

210 Views

We can write Assertions in Postman with Chai Assertion Library. Assertions are added in tests to verify if the actual and expected results are similar. In case, they are dissimilar, an Assertion error gets thrown along with the cause of the error.Boolean value of either true or false is returned by an Assertion. In Postman, Assertion is handled by Chai Assertion Library which is developed in JavaScript. It is provided in the Postman application by default.Assertions in Postman are added under the Tests tab. The documentation of the Chai library details are present in the link − https://www.chaijs.com/.Let us create ... Read More

How to get the response in different format in Mock Server using Postman?

Debomita Bhattacharjee
Updated on 03-Aug-2021 13:37:52

632 Views

We can get the Response in different formats in Mock Server. A Mock Server is created to avoid sending requests on the real time or production data. The steps to create a Response in different format in Mock Server are listed below −Step 1 − Click on New from the top of the Postman application. Then click on the Mock Server link.Step 2 − Choose the option GET from the Method field. Add /user/home in the Request Path, 200 in Response Code and the text – This is Postman Tutori in Tutorialspoint in the Response Body field.Step 3 − Provide ... Read More

How to Import Collection in Postman?

Debomita Bhattacharjee
Updated on 03-Aug-2021 13:30:48

2K+ Views

We can import Collections in Postman. To perform the this task, follow the below steps −Step 1 − Click on the Import menu in the Postman application.Step 2 − Import pop-up shall open with the options to import from a File, Folder, Link, Raw text and Code Repository.Step 3 − We can either import by clicking on the Upload Files button or by drag and drop option. From the Code repository tab, we can import from GitHub.

How to set Test and Collection Runner in Postman?

Debomita Bhattacharjee
Updated on 03-Aug-2021 13:29:17

697 Views

We can add test verifications to the Response obtained from a request with the help of scripts. These scripts are incorporated in the Tests tab. The tests only get executed provided the request is successful.A test developed under the Tests tab is written in JavaScript. Once a request is sent, a Response is obtained along with the test results in the Test Results tab. Tests which have passed are marked in green and the failed ones are marked in red.Add the below JavaScript verifications within the Tests tab −tests["Status Code should be 200"] = responseCode.code === 200 tests["Response time lesser ... Read More

Different types of Asserts in Postman

Debomita Bhattacharjee
Updated on 03-Aug-2021 13:22:58

252 Views

There are different types of Asserts in Postman. We can add Assertions on different sections of the Response received. Some of the Assert types are listed below −Assert on Response Codepm.test["Status Code is 200"], function(){    pm.response.to.have.status(200) })The above assertion passes if the Response code is 200.pm.test["Status is OK"], function(){    pm.response.to.have.property('status', ' OK') })The above assertion is applied on the Response property – status with value as OK.Assert on Response timepm.test("Response time below 600 milliseconds", function () {    pm.expect(pm.response.responseTime).to.be.below(600) })The above assertion passes if the Response time is below 600ms.Assert on Response Formatpm.test("Response is of JSON type ", ... Read More

Executing Tests on Cookies in Postman

Debomita Bhattacharjee
Updated on 03-Aug-2021 13:18:37

1K+ Views

We can execute Tests on Cookies in Postman. Once a request gets executed for an endpoint, a Response gets generated. Within a Response, the cookie information gets generated under the Cookies tab.We can add Tests script around cookies and apply Assertions on them for verification. Test scripts are incorporated under the Tests tab. Let us add the below script to verify the value of cookie – Cookie_Postman.pm.test("Verify Cookie value", function(){ pm.expect(pm.cookies.get('Cookie_Postman')).to.eql('value1')})Send the Request. After the Response is received, navigate to the Tests tab. It shows the Assertion in our Test script failed as the expected value of the Cookie_Postman is ... Read More

How to create a mock server in Postman?

Debomita Bhattacharjee
Updated on 03-Aug-2021 13:16:29

357 Views

We can create a Mock Server in Postman. A Mock Server is used to simulate the working of an actual server to test APIs and Responses. These are very common if certain APIs require to be tested but they are presently unavailable on the web servers due to security concerns on the real server.The steps to create a Mock Server are listed below -Step 1 − Click on New from the top of the Postman application. Then click on the Mock Server link.Step 2 − Choose the option GET from the Method field, add a Request Path as /user/home, enter ... Read More

Authenticating by encoding through Postman

Debomita Bhattacharjee
Updated on 03-Aug-2021 13:11:49

2K+ Views

In Postman, sometimes we need to verify the eligibility of a user accessing a particular resource on the server. This is done by authenticating the credentials of a user by the system.Thus authentication helps to identify the identity of a user and is applied for the secured APIs. In Postman, this is carried out under the Authorization tab. The TYPE dropdown in the Authorization tab, lists down all the Authorization types.To carry out an encoded authentication, we have to choose the option No Auth from the TYPE dropdown in the Authorization tab and simultaneously from the Headers tab, we have ... Read More

What is an Environment Variable in Postman?

Debomita Bhattacharjee
Updated on 03-Aug-2021 13:09:56

563 Views

A variable is used to store and add parameters in a request, Collection, scripts and so on. An Environment in Postman comprises a key-value pair. The key in an Environment is known as the Environment variable.An Environment variable has a local scope which means a variable defined within an Environment can be accessed in the same Environment in which it is created. In case we try to access that variable outside the Environment in which it is created, we shall encounter errors.To create an Environment variable we have to follow the below steps −Step 1 − Click on the New ... Read More

What is Newman in Postman?

Debomita Bhattacharjee
Updated on 03-Aug-2021 13:04:46

736 Views

The command-line runner used to execute requests and verify Response in Postman is known as Newman. Apart from the Collection Runner, the Newman can also be used for triggering requests in a Postman Collection.Newman works well with NPM registry and GitHub. It can also be integrated with Continuous Integration tools like Jenkin. Newman generates the code 0 if all the requests get executed successfully.The code 1 is generated in case of errors. These codes can be interpreted by the CI tool. Newman is developed on node.js and utilizes the npm package manager. To install Newman follow the below steps −Step ... Read More

Advertisements