API Testing Flashcards
What is an API?
API ⇒ Application Programming Interface.
API is the middle layer that is between the application User Interface and Database.
API handles data transfer between UI to Database and vice versa.
What are the differences between REST and SOAP?
SOAP ⇒ Simple Object Access Protocol.
* Only works with XML.
* Only has 1 HTTP method as ‘POST’.
* WSDL (web services description language) provides detailed information about the SOAP services.
* Envelope structure. (message to server)
* UDDI registry.
REST ⇒ REpresentational State Transfer.
* Accepts multiple data transfer methods: GET, POST, PUT, PATCH, DELETE.
* Faster performance.
* More flexible.
* Set of architectural guidelines.
What is the difference between an API and a Webservice?
All Webservices are API’s that use the internet. (using HTTP protocol)
There are API’s that do not use the internet and they are just called API’s.
Example of API that does not use the internet:
The Windows API is a collection of functions and routines that allow software applications to interact with the Windows operating system. It doesn’t rely on internet connectivity and is used for various tasks such as file operations, user interface interactions, and system management.
What do you validate when you are testing an API?
- HTTP Status code
- Response Body Validation
- Schema Validation
What are tools that can be used to perform API testing?
Manual:
* Postman
* Ready API
* SoapUI
Automation:
* Rest Assured library
What are the key differences between API and UI testing?
When we test the User interface of the application we can clearly see whether our test has passed or failed since User interface is visible.
API requests will travel to the server, the server will process the request, however the result of the request can only been seen within the API response body.
Can you automate API testing, if so how?
There are many libraries that allow API automation testing.
I began automating API’s using POSTMAN with JavaScript. Currently, I am using REST Assured library with JAVA to automate API’s.
What is URI?
URI ⇒ Uniform Resource Identifier — is a sequence of characters that distinguishes one resource from another. In the API it is the endpoint that is considered URI.
What are the REST API HTTP methods you are familiar with?
- GET ⇒ retrieve data from server,
- POST ⇒ create/insert/provide data to server,
- PUT ⇒ update based on a parameter,
- PATCH ⇒ update or create a new row if it does not exist,
- DELETE ⇒ remove the resource.
What is meant by Client and Server?
Can you provide a basic flow of an API Request/Response?
Client ⇒ Any device that submits the triggers the API requests.
Server ⇒ A server that process API requests.
|
- Step 1: Gather details of API from the documentation.
- Step 2: Create the API request call.
- Step 3: Trigger the API call.
- Step 4: Server reviews and Provides API response.
- Step 5: Perform validations for your API.
What are the main differences between XML and JSON?
XML ⇒ Bulky uses tag based structure, more secure, lower performance.
JSON ⇒ Data structure, faster performance, lower security.
What is HTTP protocol?
What is HTTPS protocol?
HTTP ⇒ HyperText Transfer Protocol.
HTTPS ⇒ HyperText Transfer Protocol Secured.
What are request Headers?
Can you provide an example?
Are Headers always required?
Headers provide extra information to the server in order to process the request.
Content-type ⇒ Application/Json
Authorization ⇒ Token
Depends on the configuration of the API whether headers are mandatory or not.
If you had to make a REST request what is the information you need?
- Endpoint / URI
- What Method using ⇒ POST,GET, PUT, PATCH, DELETE
- Headers ⇒ ask what headers are needed.
- Request Body ⇒ ask if you need a request body.
- Authorization ⇒ if it is provided in API
Can you explain how this Web service works?
A web service typically works:
- Service Definition: The provider defines the functionalities and interfaces of the web service, including the methods that can be invoked and the data formats for communication.
- Service Publication: The provider publishes the web service on a network, making it accessible to clients. This is usually done by deploying the web service to a server or a cloud platform.
- Client Access: Clients access the web service using its endpoint URL and a description document such as a WSDL (Web Services Description Language) file. Clients can be written in any programming language and can run on different platforms.
- Request-Response Cycle: Clients make requests to the web service by sending HTTP requests (typically POST or GET) with XML or JSON payloads containing the necessary data. The web service processes the request, performs the required actions, and sends back an HTTP response with the result data.
- Data Exchange: The communication between clients and the web service usually involves exchanging data in a standardized format such as XML or JSON. This allows different systems to understand and interpret the exchanged data consistently.
- Error Handling: The web service handles errors and exceptions gracefully by returning appropriate HTTP status codes (e.g., 200 for success, 400 for bad request, 500 for internal server error) and error messages in the response payload. Clients can parse the response and take appropriate action based on the status code and error message.