How to generate an access token and pass to another request in Postman?

HOME

pm.environment.set("TOKEN", pm.response.json().access_token)

Key: Authorization
Value: Bearer {{Token}}

How to set Content-Type in Postman: A Simple Guide

HOME

https://api.restful-api.dev/objects

{
   "name": "Apple MacBook Pro 16",
   "data": {
      "year": 2019,
      "price": 1849.99,
      "CPU model": "Intel Core i9",
      "Hard disk size": "1 TB"
   }
}

How to pass basic authorization token in header in Postman

Last Updated On

HOME

In this tutorial, we’ll learn how to use Postman to test an endpoint secured with Basic Authentication.

Table of Contents

What is an authorization token?

An authorization token, often referred to as an access token, is a piece of data or credential that is used to authenticate and authorize access to protected resources or operations in a system. It is a Base64-encoded string of username:password. We can send it in the Authorization header like this:

Authorization: Basic YWRtaW46cGFzc3dvcmQ=

We will use the following URL for this Postman tutorial.

https://postman-echo.com/basic-auth

Implementation Steps

Below are the steps to use Basic Auth in Postman:

Create a Collection

Step 1: Create a Collection, click on Collections, and then click on the “+” plus button.

Step 2:  Provide a name to the collection – “Authentication”.

Add a request to the Collection

Step 3: To create a new request, click on “Add a request”, if it is a new Collection. Otherwise, click on the 3 dots and select “Add request”.

Enter the details – URL, Method, Authorization

Step 4: Enter the “name” in the request. Here, the name is “Token”.

Step 5: Enter the “URL” in the address bar.

https://httpbin.org/basic-auth/user/pass

Step 6: Now, select the “GET” request from the list of request methods.


Step 9: Now, click on the Send button in Postman. The server will respond with the protected resource response message.

Verify the Response

Step 10: Once you press the send button, you will get the response from the server. Make sure you have a proper internet connection; otherwise, you will not get a response.

Status

You can check the status code. Here, we got the status code 200, which means we got a successful response to the request.

Body

In the Body tab of the response box, we have multiple options to see the response in a different format.

We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

Digest Authentication with Postman

Last Updated On

HOME

In this tutorial, we’ll learn how to use Postman to test an endpoint secured with Digest Authentication.

Table of Contents

What is Digest Authentication?

Digest Authentication is an advanced authentication method as compared to Basic Authentication. It is used in HTTP to secure the communication between the client and server. This authentication uses the hash of the password and other details rather than passing the actual password over the network. Using this Authentication method, we can make the communication more secure.

We will use the following URL for this Postman tutorial.

https://postman-echo.com/basic-auth

Implementation Steps

Below are the steps to use Basic Auth in Postman:

1. Create a Collection

Step 1: Create a Collection, click on Collections, and then click on the “+” plus button.

Step 2:  Provide a name to the collection – “Authentication”.

2. Add a request to the Collection

Step 3: To create a new request, click on “Add a request”, if it is a new Collection. Otherwise, click on the 3 dots and select “Add request”.

3. Enter the details – URL, Method, Authorization

Step 4: Enter the “name” in the request. Here, the name is “Digest Auth”.

Step 5: Enter the “URL” in the address bar.

https://postman-echo.com/digest-auth

Step 6: Now, select the “GET” request from the list of request methods.

4. Verify the Response

Step 10: Once you press the send button, you will get the response from the server. Make sure you have a proper internet connection; otherwise, you will not get a response.

4.1 Status

You can check the status code. Here, we got the status code 200, which means we got a successful response to the request.

4.2 Body

In the Body tab of the response box, we have multiple options to see the response in a different format.

4.3 Headers

Headers are the extra information that is transferred to the server or the client. In Postman, headers will show like key-value pairs under the headers tab. Click on the Headers link as shown in the below image:

We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

Basic Authentication with Postman

Last Updated On

HOME

In this tutorial, we’ll learn how to use Postman to test an endpoint secured with Basic Authentication.

Table of Contents

What is Basic Authentication?

Basic Authentication is a simple authentication scheme built into the HTTP protocol. The client sends the username and password encoded in Base64 in the Authorization header.

We will use the following URL for this Postman tutorial.

https://postman-echo.com/basic-auth

Implementation Steps

Below are the steps to use Basic Auth in Postman:

Create a Collection

Step 1: Create a Collection, click on Collections, and then click on the “+” plus button.

Step 2:  Provide a name to the collection – “Authentication”.

Add a request to the Collection

Step 3: To create a new request, click on “Add a request”, if it is a new Collection. Otherwise, click on the 3 dots and select “Add request”.

Enter the details – URL, Method, Authorization

Step 4: Enter the “name” in the request. Here, the name is “Basic Auth”.

Step 5: Enter the “URL” in the address bar.

https://postman-echo.com/basic-auth

Step 6: Now, select the “GET” request from the list of request methods.

Step 10: Now, click on the Send button in Postman. The server will respond with the protected resource response message.

Verify the Response

Step 11: Once you press the send button, you will get the response from the server. Make sure you have a proper internet connection; otherwise, you will not get a response.

Status

You can check the status code. Here, we got the status code 200, which means we got a successful response to the request.

Body

In the Body tab of the response box, we have multiple options to see the response in a different format.

Headers

Headers are the extra information that is transferred to the server or the client. In Postman, headers will show like key-value pairs under the headers tab. Click on the Headers link as shown in the below image:

We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

How to send PATCH Requests in Postman?

HOME

In this tutorial, we will send a request performing the PATCH method in Postman.

 The PATCH method is used to partially modify an existing resource. This operation updates an existing resource but does not require sending the entire body with the request. PUT modifies a record’s information and creates a new record if one is not available, and PATCH updates a resource without sending the entire body of the request. Unlike PUT Request, PATCH does partial update e.g. Fields that need to be updated by the client, only that field is updated without modifying the other field.

We will use the following URL for this Postman tutorial.

https://reqres.in/api/users/2

Sample Request Body

{
    "name": "Patch_Test"
}

To create the first PATCH request in Postman, follow the following steps:

Step 1: Create a Collection, click on Collections, and then click on the “+” plus button.

Step 2:  Provide a name to the collection – “API Testing”.

Step 3: To create a new request, click on “Add a request” if it is a new Collection. Otherwise, click on the 3 dots and select “Add request”.

Step 4: Once you create a new request, then you will get the following window:

Step 5: Enter the “name” in the request. Here, the name is “PartiallyUpdateUser”.

Step 6: Enter the “URL” in the address bar.

Step 7: Now, select the “PATCH” request from the list of request methods.

Step 8: Add a Request body to the Post request

For this, select the Body tab.

Now in the Body tab, select raw and select JSON as the format type from the drop-down menu, as shown in the image below. This is done because we need to send the request in the appropriate format that the server expects. Copy and paste the request body example mentioned at the beginning of the tutorial to the postman request Body. 

Step 9: Press the “Send” button.

Step 10: Once you press the send button, you will get the response from the server. Make sure you have a proper internet connection; otherwise, you will not get a response.

Status

You can check the status code. Here, we got the status code 200, which means we got a successful response to the request. In the case of new resource creation, the status code should be 201. But as this is a dummy API, we are getting a status code of 200.

Body

In the Body tab of the response box, we have multiple options to see the response in a different format.

Format Type

Each request has a defined response to it as defined by the Content-Type header. That response can be in any format. Such as in the above example, we have JSON code file.

Below are the various format type present in Postman.

XML

HTML

Text

Headers

Headers are the extra information that is transferred to the server or the client. In Postman, headers will show like key-value pairs under the headers tab. Click on the Headers link as shown in the below image:

We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

How to send SOAP request in Postman?

HOME

In this tutorial, we will send a SOAP Request in Postman.

What is a SOAP Request?

POST requests are used to send data to the API server to create or update a resource. The data sent to the server is stored in the request body of the HTTP request.
HTTP POST request provides additional data from the client to the server message body.

We will use the following URL for this Postman tutorial.

https://www.dataaccess.com/webservicesserver/NumberConversion.wso

Sample Request Body

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <NumberToWords xmlns="http://www.dataaccess.com/webservicesserver/">
      <ubiNum>1525</ubiNum>
    </NumberToWords>
  </soap:Body>
</soap:Envelope>

To create the a SOAP request in Postman, follow the following steps:

Step 1: Create a Collection, click on Collections, and then click on the “+” plus button.

Step 2:  Provide a name to the collection – “API Testing”.

Step 3: To create a new request, click on “Add a request” if it is a new Collection. Otherwise, click on the 3 dots and select “Add request”.

Step 4: Once you create a new request, then you will get the following window:

Step 5: Enter the “name” in the request. Here, the name is “SOAP_Request”.

Step 6: Enter the “URL” in the address bar.

Step 7: Now, select the “POST” request from the list of request methods.

Step 8 – Add a Request body to the Post request

For this, select the Body tab.

Now in the Body tab, select raw and select XML as the format type from the drop-down menu, as shown in the image below. This is done because we need to send the request in the appropriate format that the server expects. Copy and paste the request body example mentioned at the beginning of the tutorial to the postman request Body. 

Step 9: Add “Content-Type” to the Header.

Here, Content-Type is text/xml; charset=utf-8.

Step 10: Press the “Send” button.

Step 11: Once you press the send button, you will get the response from the server. Make sure you have a proper internet connection; otherwise, you will not get a response.

Status

You can check the status code. Here, we got the status code 200, which means we got a successful response to the request. In the case of new resource creation, the status code should be 201. But as this is a dummy API, we are getting a status code of 200.

Body

In the Body tab of the response box, we have multiple options to see the response in a different format.

Format Type

Each request has a defined response to it as defined by the Content-Type header. That response can be in any format. Such as in the above example, we have XML code file.

Below are the various format type present in Postman.

JSON

HTML

Text

Headers

Headers are the extra information that is transferred to the server or the client. In Postman, headers will show like key-value pairs under the headers tab. Click on the Headers link as shown in the below image:

We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

What is API Chaining in Postman?

HOME

What is API Chaining?

The API chaining method is to create a sequence of API calls where the output of one API request is used as the input for the next. The technique is an automated and efficient way of executing a Multistep Process.

We will learn to get a response from one API and pass it as a request parameter in another API.

How to create a Collection?

Step 1: Create a Collection, click on Collections, and then click on the “+” plus button.

Add 2 requests in the Postman

https://reqres.in/api/users?page=1

https://reqres.in/api/users/4
{
    "name": "Test",
    "job": "zion resident"
}

pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});

var jsonData = pm.response.json();
value = jsonData.data[2].first_name
console.log(value)

pm.environment.set("Username", value);

pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});

How to run Collections remotely in Postman?

HOME

newman run <copied URL>

How to schedule Collection run in Postman?

HOME