Tuesday, 13 June 2017

First Test Case for Rest API on Postman

Let's start creating the first test case for Rest API in postman tool by following the below steps:

1. Select a URI (REST API URL) and placed it to the Enter Request URL field of Postman tool.


2. Select the request type from the list of requests. Here i have selected the GET request.


In case of GET request, no need to send anything in the body section, that is why body section is disabled here.

3. Click on the send button.
Once you click on the send button, request would be sent to the given server and response would be received.

The above response received is in JSON format. There are many more ways to view the response like HTML, XML, Text and Auto.

There is an option named as History to view all the previous requests that you had sent.


Thursday, 8 June 2017

Set Up POSTMAN Environment in Google Chrome

Set Up Postman on Chrome Browser: POSTMAN is an extension of Chrome Browser and to get it on browser follow below steps:

1. In Google, type install postman. And click on first search result.

Installation Steps

2. Once click on the above link, it would open in the chrome browser extension. And click on the Add to Chrome button.



3. After clicking on Add App button, it downloads the postman app and add it to the chrome extension automatically.


4. When it is added to the chrome, one message displays "Added to chrome extension successfully". This can also be checked by using this command on chrome browser "chrome://apps" and click enter. If it is added successfully, it would be shown in the list like below:




5. To open the Postman there are 2 ways:
(a) Just click on the above mentioned link and tool will be launched. And it would ask for the registration.


Or can go the tool initially by just click on the link "Take me straight to the app. I will create the account another time". And the tool would be open.

(b) Go to the run type postman and click on appeared postman link, the tool would be opened.

Now can use the tool to send request to the server.


Basics of JSON

JSON is JavaScript Object Notation, it is minimal and readable format for structuring the data. It is used to communicate between server and web application. It is an alternative of XML.

JSON Rules:
1. It is always written in curly braces {}.
2. Data is written in Key, Value pair.
3. Key can have more than one value.

JSON Example:
{
   "Title": "Spiderman"
   "Year": "1990"
   "Released": "N/A"
   "Producer" : ["Name1","Name2"]
}

4. If a key has more than one value, it would be stored in an Array.

In the above example, Title is the key and Spiderman is its value. And the producer key contains more the one value and stored in an Array like [].

5. Keys can have sub keys and Values, known as Object.

JSON Example:
{
    "fields": {
       "summary" : {
           "details" : "True"  
}

Here "fields" is an object.

Tuesday, 6 June 2017

REST API Request Methods

Here is the list of methods used to send the request to the server:

1. GET
2. POST
3. PUT
4. DELETE
5. PATCH
6. HEAD
7. OPTIONS
8. TRACE

From the above list Head, Options, Trace are used very rarely.
Below is the details for each method:

GET: When you want to retrieve some data from the server, use GET method. 
For eg: To fetch the deatil of a bug from the JIRA server, use GET method.

POST: When you want to create new resource to the server, use POST method.
For Eg: In JIRA tool, if you want to add new bug, use POST method.

PUT: When you want to update some data to the existing resource, use PUT method. In this user needs to send the complete data set together.
For Eg: If user want to update the summary of a existing bug, needs to send the Bug Id, Bug Name, Update Bug Summary etc.

DELETE: When you want to delete some data or some resource from the server, use DELETE method.

PATCH: Patch is almost same as put method (used to update some data to the existing resource). The only difference in Patch is only updated data needs to be sent with no other details.

HEAD: Head is used when you want to get only header in the response from the server like cookie, content type of response etc.

OPTIONS: This method gives the list of methods that can be used to hit the API to retrieve the data.

TRACE: Trace is used to check the format to the request, whatever we are sending to the server, can retrieve the same. Basically used for the debugging purpose.

Friday, 2 June 2017

Difference between SOAP and REST



S.No

1.


2.


3.

4.


5.


6.


7.


8.
SOAP

SOAP stands for Simple Object Access Protocol.

SOAP uses WSDL to communicate with web service.

SOAP is a protocol.

SOAP uses services interface to expose the business logic.

SOAP defines W3C standards strictly to be followed.

SOAP requires more bandwidth and resource.

SOAP defines its own security.


SOAP permits XML data format only.
REST

REST stands for Representational State Transfer.

REST uses WADL to communicate with web service.

REST is a architectural style.

REST uses URI to expose the business logic.

REST does not define any standard like SOAP.

REST requires less bandwidth and resource.

REST inherits security measure from the underlying transport.

REST allows multiple file format like plain text, XML, JSON, HTML etc.

More about WSDL and WADL

WSDL

WSDL stands for Web Service Description Language, is a base file written in XML format and used to describe web service and how to access it. It basically contains location of web service and operations exposed by that web service.

WSDL Elements: It has following major elements:
<types> - Describe the data type used by web service
<message> - Messages used by web service
<porttype> - Operation performed by web service
<binding> - Communication protocol used in web service


WADL

WADL stands for Web Application Description Language written in XML format that contains all the functionalities can be performed by web service in terms of Resource. It is basically designed to provide a machine process-able description of HTTP based web application.

WADL Elements: It has following major elements:
<resources> - Contains list of resources
<method> - Describe the input to and output from HTTP protocol
<request>- Describe the input to be included when applying to an HTTP
<response> - Describe the output to be received from HTTP.
<representation> - Describe a representation of resource's state.

Thursday, 1 June 2017

What is Web Service and its types?

"Web Service allows a program to interact with server/engine, instead of using browser to open a web page".
It means Web Service is a kind of application which is deployed on server and when user wants to access that service, they need to write the program in any supporting language. Web service does not provide any UI (user interface). Here the user written program would be the only medium to send input to the server and receive output from the server.

For Example: Google has provided many web services like Weather, Currency Converter etc.
Suppose if you want to show the weather information on your website, there is no need to rewrite the web service for weather, you can use that google already written weather web service by just procuring its license. By this way you just need to design and interactive program (may be in XML) to display the received response from that web service.

Web Services Types- Web services are divided into 2 categories:
1. SOAP (Simple Object Access Protocol)
2. REST (Representation State Transfer)

SOAP Services

Below are the features of SOAP services:
1. It stands for Simple Object Access Protocol.
2. It is used to exchange the message between service and application in XML format.
3. SOAP is itself a protocol which used HTTP protocol to transfer the data between application and web service.
4. SOAP is a wrapper over the HTTP protocol (this implies that in SOAP two protocols are used: SOAP and HTTP).
5. It is a Standard, Conventional and Heavy.
Why Heavy?
In SOAP, request and response both are in XML format and XML file have start and end tag for a single tag.
6. SOAP uses WSDL (Web Service Description Language) (About WSDL will learn in next post).

REST Services

Below are the features of REST services:
1. REST is a set of guidelines that describes how a client should interact with the server.
2. The data and functionality which client can access from the server are known as the resource.
3. REST services use HTTP or other similar protocol which supports Get, Post, Put and Delete operations.
4. REST services use WADL (Web Application Description Language).
5. It is New and Light weighted approach.
6. In REST functionality can be accessed by unique URI. In WADL each functionality has unique URI.
7. In REST services, response can be received in different format like plain text, HTML, XML, JSON, PDF etc.

First Test Case for Rest API on Postman

Let's start creating the first test case for Rest API in postman tool by following the below steps: 1. Select a URI (REST API UR...