Codementor Events

POSTMAN - Lets Fly with API’s

Published Jan 12, 2018
POSTMAN - Lets Fly with API’s

What is Postman?

A powerful GUI platform to make your API development faster & easier, from building API requests through testing, documentation and sharing.

What is Problem of Developers like Me?

I have started my career in 2013 and use of Postman too. While developing Android Application I had developed Web Services too.

There are so many problems to test API’s for passing data to Android Applications because we are spending almost time to make HTML Forms and posting request on particular API then testing and changes. Just repeating cycle everytime.

Its very difficult process to manage request and response everytime. For example, If we add new params in POST request then we have to add in HTML view and Test it again.

Solution is POSTMAN:

I used to with forms of HTML and all in between I came to know about Postman. I had implemented and worked with it, and after all we are (in my company) just use Postman only.

Today I am going to take presentation so I thought to share my experience with this post. Hope you will enjoy.

Lets play with POSTMAN:

Its Very Easy to Download and Install from website or Chrome Extension.

Basic Features:

When testing an API, you can select your desired HTTP method, such as Get, Post, or Put.


HTTP Methods in POSTMAN

What I loved most? Variables :

Variables are symbols that can take different values. You might be familiar with variables from other languages from your prior programming experience. Variables in Postman work the same way.

Variables allow you to reuse values in multiple places so you can keep your code DRY (Don’t Repeat Yourself). Also, if you want to change the value, you can change the variable once with the impact cascading through the rest of your code.

Let’s say you have 3 API endpoints that use the same domain — your-domain.com. You can save this domain as a variable and instead of repeating the value, you can use {{domain}}/endpoint1and {{domain}}/endpoint2 in the request builder. Now, if your domain changes to another-domain.com, you just have to change this value once.

With Postman’s scripting engine you can set variable values, copy data from one request and use it into another request, and more.

Lets take an example:

1. Global Variable:


Response of Login Request — POSTMAN

I am getting this response in my login request, Now I have to use access_token in every other requests.

For example, If I have suppose 20 request then I must have to change all the request with new access_token.


Saving values as Global Variable

So now I had set access_token and other required values as a global variable of postman.

So it will be use in Post Request now, as {{token}} and {{global_user_id}}


Written in Test(as above):

var jsonData = JSON.parse(responseBody); 
postman.setGlobalVariable(“token”, ‘bearer ‘ + jsonData.access_token);
postman.setGlobalVariable(“global_user_id”, jsonData.profile.global_user_id);

2. Environment Variable:

If you need to pass the value from one API result (for example, an authentication token as parameter to another API call), you can make use of its “Manage Environments” feature.

Using “Manage Environments” , you can set up different environment variables, either global or within a defined scope.

For example, “url” variable is set up below as a global variable to use as local url and server url.


Manage Variable

Now I will use {{url}} in url of request and it will take automatically that variable value.

Collection and Share:

The Beauty of Postman is that you can save related API endpoints into a collection and share the entire collection to other developers. Once they get the collection link, they can import the collection and continue with your work without any extra effort.

Hope its quite useful.

There are so many things to play with POSTMAN but as a developer you must have to know this things. There are still a lot of good features from Postman, but these are enough for you to build and test your API efficiently.

You can explore more with Documentation

Follow Me or Visit My Website for More Articles.

Dont forget to ❤ it if you really enjoyed.

Thank you.

Discover and read more posts from Pratik Butani
get started
post commentsBe the first to share your opinion
Show more replies