Saturday, February 8, 2014

How to test Google Contacts functions through Google Contacts API using Postman?

In my previous post, I have explained you how you can install Postman- Rest- Client extension in your Google Chrome Web browser and why we need such tool. In the same post, I mentioned that I will be explaining it more in another post on how to use postman to test a real world API and make sure its functionalists are working as expected. So, here we go guys.

This post is based on testing Google Contacts API functions (not all but few of them) in Postman-Rest-Client tool.

Prerequisites

  • As u already know, we need to have Google Chrome running in your machine with the Postman extension installed in it.
  • You must have a Google Contacts account. Don't worry, if you do have a gmail account, you will be having a Google Contacts account as well. All you need to do is to login to it at least once using the following url.
  • Of course, you need to have Contacts in your account to start testing any function given in the api.
  • You need to refer the Google Contacts API documentation well before starting to test them. The below link will direct you to the latest version of it.
  • The most important thing is you need to obtain an authorization access token from Google Developers' OAuth 2.0 Playground. Follow the below link to obtain it and note i will explain you how to get the access token step by step.

Great. Now, let's go from point zero :) 

I assume everyone has a gmail account so that a Google Contacts account too. So, let me explain you how to obtain an access token from Google Developers' OAuth 2.0 playground.

Obtaining an Autherization access token from Google Developers' OAuth 2.0 playground for Google Contacts


1.Go to the link below


2.



3.



4.




5.




6.





Note that the obtained access token expires within the time that is mentioned above so that you have to use that for testing before it expires. But once it's expired, you can refresh and obtain  a new access token to continue testing.

So, I hope it's clear up to this level. Next is simply to get a function, identify its parameters etc and test for it's response through postman-Rest client tool.

Before that, we have to confirm the function that we are going to test, don't we? Refer the below link and focus on the function that is highlighted in the below screenshot that is taken from the Google Contacts API documentation page.





















Check the below shown screenshot to identify the function correctly.
















How to test the Retrieve All contacts function in postman?


Open Postman-Rest-API plugin in your Google Chrome Web Browser and Click Reset button to clear any existing tests that you have been working with. Then set the below values in front of the below shown fields accordingly.

Set the url in the below format:-
https://www.google.com/m8/feeds/contacts/<your email address>/full

Add a Header call Authorization and add the value as shown below (note that your access token shouldn't be expired at the time you are using it to test):-

Bearer <the access token you obtained above>

Select the type of the http call as :-

GET

and finally click Send button to obtain the response.

for an example, refer the below screenshot




















If you didn't enter an email in the request url, then the default email will be used which means the account that you have currently logged in.

I hope the post was clear enough for you to start with Postman to test API functions. Hope it was useful to you :) See you in another interesting post ...

Using Postman to test API functions easily

Hi all, after a long break for blogging, I wanted to post something really interesting that I found while working with my new client project which basically needs to create connectors for an ESB to connect to a large set of popular APIs.

While working in the project, we faced so many issues where we wanted to make sure that the functionalists of APIs work as expected. Note the words "as expected". So, how are we going to make sure what the functions going to return and in which format will they be? Of course a well documented API should mention them but what if they didn't? And speaking with my own experience that some of the API documentations even contain functions that are deprecated or not in use but not mentioned them clearly in the API documentation. Here comes the usage of 'postman'. I assume you guys heard the word before and have experience in using it to test APIs but don't worry if u heard the word for the very first time since this post is for you guys.

So, What is Postman?


Please follow this Link to find more information about this plugin.


Postman Rest Client is an extension in Google Chrome web browser which can be found in Google Web Store. You can simply install it in your browser by following the above link and following the below screenshots.





















Notice that the extension will be downloaded and installed automatically in your web browser as shown below.




















Once it's installed, then open a new tab in chrome and you will see the postman icon as shown below.



















So, there we go. We can start using postman as we wish.

Short Description of what Postman does

Postman helps you be more efficient while working with APIs. Postman is a scratch-your-own-itch project. The need for it arose while one of the developers was creating an API for his project. After looking around for a number of tools, nothing felt just right. The primary features added initially were a history of sent requests and collections. A number of other features have been added since then.

If you found an API and if you want to test a function having the necessary headers, parameters and method type basically, you can simply test them in postman to make sure that it works as expected.

My next post will be on how to use postman for a selected API. In that, I wish I can explain more about it. 

Hope this post was useful to you guys :)

Find more information from the below Link