How to use postman for API Testing

How to use postman for API Testing

“How to use Postman for API testing” is one of the most convenient ways of backend testing these days.

Please find below the concepts on How to use Postman for API testing

How to chain API requests in postman?

For example, there are two API requests, Request A and Request B. Executing Request A produces some responses which we have to use as input in the next Request B. In simple terms, we can say the output of request A will become the input or Request B. This is known as API request chaining. 

Let us take an example here, 

  • We will create a collection with a GET request and a PUT request.
REQUESTURI
GEThttp://localhost:3000/users
PUThttp://localhost:3000/users/4
  • Inside the collection, we will define a collection variable.

VARIABLE

  • Now in the Test tab of the GET request, we will write a piece of code.
jsonData=JSON.parse(responseBody)parsing the response into a variable
value= jsonData[0].nameextracting the value of “name” field into a variable
pm.globals.set(“username”,value);updating the variable value with the name
 
 
 
  • After saving now run the collection

What are the types of authorization available in postman and how to use them?

In the authorization, tab postman provides us with various types of authorizations like No Auth, API Key, Basic Auth, Digest Auth and AWS Signature etc. We will see some of the most commonly used authorization in the API requests.

1- Basic Authorisation

In basic authorization, we just have to pass the username and the password to authenticate the request. 

authorisation
basic authorization

2- API Key

Here we have to complete the authentication with the provided API key.

API KEY
API KEY

3- Bearer Token / O Auth 2.0 

OAuth Authentication
OAuth Authentication

CHECK NEXT PART

Wikipedia API

About Postman

Leave a Comment

Your email address will not be published.