Hi friends, today we are going to discuss API Testing. While testing, lots of time we came across the words request, response, output etc. These words have predefined meaning. We will go step by step to know about API Testing.
What is API?
API is “Application Programming Interface”. API mainly used for data communication between two modules or systems. A source sends a request to destination and destination sends a response to the source using API.
Types of API’s :
REST and SOAP are the types of API’s. Most of the times developer choose to go with REST API structure style. REST is lighter than SOAP.
REST is “Representational State Transfer”. REST is an architecture style while SOAP is a protocol. REST based web services use URI. URI is “ Uniform Resource Identifiers. REST web services are in resource structure architecture. The resource would be a chunk of respective information e.g. User id, profile etc.
Rest uses simple HTTP calls to access resources. The application sends a request to another system/backend/module and the destination will send a response to the application.
How RESTful service works?
RESTful services use HTTP verbs to determine the which operation to be performed.
GET method: To get an information
PUT method: To update an information
POST method: To create an information
DELETE: To delete an information
Let’s take an example of how REST API works.
There are lots of tools available like Postman, Poster etc to verify request and response. Here I am using Charles tool. Using this tool user can send a request and test the desired output is coming or not. Also, a user can edit the request with test data as an input and test the desired output with respect to given input.
To use Charles you need to put “Request URL” in the browser tab (Request URL can be taken from -> Inspect header element by hitting the desired URL). Refer below screenshot.
Charles Session for the Desired request:
If you want to edit the request you need to right click on the request and provide desired input and click on execute. After execution check for desired output.
SOAP is “Simple Object Access Protocol”. SOAP is the XML based protocol used for connecting the application with the backend. SOAP API is language independent platform. It must be parsed before use as it uses XML formatting.
For SOAP, the testing user must give a file in WSDL format. WSDL is: “Web Services Description Language”. The user can use SOAPUI tool for testing SOAP API.
SOAPUI Link: https://www.soapui.org/downloads/soapui.html
WSDL file for API: Sample WSDL file for test / to get start off: https://www.soapui.org/getting-started/your-first-soapui-project.html
Let’s take an e.g. In SOAPUI, we need to add desired WSDL file which we want to test.
Install SOAPUI tool
Click on ADD new Project
Right-click on the project and then Add desired WSDL file and click on ok.
After adding necessary prerequisites, click on SOAP and provide desired input XML for appropriate output.
Hope this information helps you. Wishing you a very happy API Testing.
Author: Omkaar Deshpande
Email : firstname.lastname@example.org