API
- API stands for Application Programming Interface. API is a set of routines, protocols, and tools for building Software Applications.
- Routine: a program that performs a particular task. Routine is also known as procedure, function, or subroutine.
- Protocols: A format for transmitting data between two systems.
- API acts as an interface between two software applications and allows the two software applications to communicate with each other.
- API is a collection of software functions that can be executed by another software program.
- An API is essentially a tool for developers to communicate or fetch data with a certain application.
- An API can be written and used for
- Web Based applications
- Computer operating systems
- Database systems
- Computer hardware
- Software Library
- Api which are developed to communicate through web is call web services
- The web services are the Implementation of APIs to communicate between 2 applications over a network, usually http or https
- Web service is an API wrapped in HTTP.
- Web service needs a network,however an API does not need a network
- All web services are api but all apis are not web services
WebServices API types
- SOAP
- XML – RPC
- JSON – RPC
- REST – Representational State Transfer
API Testing
- API testing is a type of software testing that involves testing APIs directly and also as a part of integration testing to check whether the API meets expectations in terms of functionality, reliability, performance, and security of an application.
- In API Testing our main focus will be on a Business logic layer of the software architecture. API testing can be performed on any software system which contains multiple APIs.
- API testing won’t concentrate on the look and feel of the application. API testing is entirely different from GUI Testing.
API Testing Types?
API testing typically involves the following practices:
- Unit testing: To test the functionality of individual operation
- Functional testing: To test the functionality of broader scenarios by using a block of unit test results tested together
- Load testing: To test the functionality and performance under load
- Runtime/Error Detection: To monitor an application to identify problems such as exceptions and resource leaks
- Security testing: To ensure that the implementation of the API is secure from external threats
- UI testing: It is performed as part of end-to-end integration tests to make sure every aspect of the user interface functions as expected
- Interoperability and WS Compliance testing: Interoperability and WS Compliance Testing is a type of testing that applies to SOAP APIs. Interoperability between SOAP APIs is checked by ensuring conformance to the Web Services Interoperability profiles. WS-* compliance is tested to ensure standards such as WS-Addressing, WS-Discovery, WS-Federation, WS-Policy, WS-Security, and WS-Trust are properly implemented and utilized
- Penetration testing: To find vulnerabilities of an application from attackers
- Fuzz testing: To test the API by forcibly input into the system in order to attempt a forced crash
Common tests on APIs:
Some of the common tests we perform on APIs are as follows.
- To verify whether the return value is based on the input condition. The response of the APIs should be verified based on the request.
- To verify whether the system is authenticating the outcome when the API is updating any data structure
- To verify whether the API triggers some other event or request another API
- To verify the behavior of the API when there is no return value
Advantages of API Testing:
- API Testing is time effective when compared to GUI Testing. API test automation requires less code so it can provide faster and better test coverage.
- API Testing helps us to reduce the testing cost. With API Testing we can find minor bugs before the GUI Testing. These minor bugs will become bigger during GUI Testing. So finding those bugs in the API Testing will be cost-effective to the Company.
- API Testing is language independent.
- API Testing is quite helpful in testing Core Functionality. We can test the APIs without a user interface. In GUI Testing, we need to wait until the application is available to test the core functionalities.
- API Testing helps us to reduce the risks.
What exactly needs to be verified in API Testing?
Basically, on API Testing, we send a request to the API with the known data and we analyse the response.
- Data accuracy
- HTTP status codes
- Response time
- Error codes in case API return any errors
- Authorization checks
- Non-functional testing such as performance testing, security testing
Challenges in API testing:
Some of the challenges we face while doing API testing are as follows
- Selecting proper parameters and its combinations
- Categorizing the parameters properly
- Proper call sequencing is required as this may lead to inadequate coverage in testing
- Verifying and validating the output
- Due to absence of GUI it is quite difficult to provide input values
Types of bugs we face when performing API testing:
Issues observed when performing API testing are
- Stress, performance, and security issues
- Duplicate or missing functionality
- Reliability issues
- Improper messaging
- Incompatible error handling mechanism
- Multi-threaded issues
- Improper errors
API Testing Best Practices:
- Test for the expected results
- Add stress to the system by sending series of API load tests
- Group API test cases by test category
- Create test cases with all possible inputs combinations for complete test coverage
- Prioritize API function calls to make it easy to test
- Create tests to handle unforeseen problems
- Automate API testing wherever it is possible
Rest Api Constraints
- Uniform Interface
- Stateless
- Cachable
- Client Server
- Layered System
- Code on Demand
Interview Questions and Answers
1. What is an API?
2. What is API Testing?
3. What are the common API Testing Types?
4. Name some of the common protocols used in API Testing?
Some of the protocols using in API Testing are as follows:
- HTTP
- REST
- SOAP
- JMS
- UDDI
5. Difference between API and Web services?
Web services:
1. All web services are APIs
2. All web services need to be exposed over web(HTTP)
3. A Web service uses only three styles of use: SOAP, REST and XML-RPC for communication
4. A Web service always needs a network to operate
APIs:
1. All APIs are not web services
2. All APIs need not be exposed over web(i.e. HTTP)
3. API uses multiple ways for communication e.g. DLL files in C/C++, Jar files/ RMI in java, Interrupts in Linux kernel API etc.
4. APIs don’t need a network for operation
6. What is Soap?
SOAP stands for Simple Object Access Protocol. It is an XML based messaging protocol. It helps in exchanging information among computers.
7. What is Rest API?
REST stands for Representational State Transfer. It is a set of functions helping developers in performing requests and receive responses. Interaction is made through HTTP Protocol in REST API
8. Difference between SOAP and REST?
SOAP:
1. SOAP is a protocol through which two computers communicate by sharing XML document
2. SOAP supports only XML format
3. SOAP does not support caching
4. SOAP is slower than REST
5. SOAP is like a custom desktop application, closely connected to the server
6. SOAP runs on HTTP but envelopes the message
REST:
1. REST is a service architecture and design for network-based software architecture
2. REST supports different data formats
3. REST supports caching
4. REST is faster than SOAP
5. REST client is just like a browser and uses standard methods An application has to fit inside it
6. REST uses the HTTP headers to hold meta information
9. What are the common tests that are performed on APIs?
Some of the common tests we perform on APIs are as follows.
1. Verify whether the return value is based on the input condition. The response of the APIs should be verified based on the request.
2. Verify whether the system is authenticating the outcome when the API is updating any data structure
3. Verify whether the API triggers some other event or request another API
4. Verify the behavior of the API when there is no return value
10. What are the advantages of API Testing?
11. What exactly needs to be verified in API Testing?
Basically, on API Testing, we send a request to the API with the known data and we analyze the response.
1. Data accuracy
2. HTTP status codes
3. Response time
3. Error codes in case API return any errors
4. Authorization checks
5. Non-functional testing such as performance testing, security testing
13. List some most used templates for API documentation?
Some of the API documentation templates are as follows.
- Swagger
- FlatDoc
- RestDoc
- API blueprint
- Slate
- Miredot
- Web service API Specification.
14. Name some of the API examples which are quite popular.
Some of the popular API examples are
- Google Maps API
- YouTube
- Amazon Advertising API
15. Difference between API testing and Unit Testing?
UNIT TESTING:
- Unit testing is conducted by the Development Team
- Unit testing is a form of White box testing
- Unit testing is conducted prior to the process of including the code in the build
- Source code is involved in Unit testing
- In unit testing, the scope of testing is limited, so only basic functionalities are considered for testing
API TESTING:
- API testing is conducted by QA Team
- API testing is a form of Black box testing
- API testing is conducted after the build is ready for testing
- Source code is not involved in API testing
- In API testing, the scope of testing is wide, so all the issues that are functional are considered for testing
16. What are the main challenges faced in API testing?
17. What are the types of bugs we face when performing API testing?
18. How is UI testing is not similar to API testing?
19. Name some most commonly used HTTP methods?
Some of the HTTP methods are
GET: It enables you to retrieve data from a server
POST: It enables you to add data to an existing file or resource in a server
PUT: It lets you replace an existing file or resource in a server
DELETE: It lets you delete data from a server
PATCH: It is used to apply partial modifications to a resource
OPTIONS: It is used to describe the communication options for the target resource
HEAD: It asks for a response identical to that of a GET request, but without the response body
20. Can you use GET request instead of PUT to create a resource?
No, GET request only allows read only rights. It enables you to retrieve data from a server but not create a resource. PUT or POST methods should be used to create a resource.
21. What is the difference between PUT and POST methods?
PUT and POST methods are sometimes confused in regards to when each should be used. Using POST request, our intent is to create a new object on the server whereas with PUT request, our intent is to replace an object by another object.
POST should be used when the client sends the page to the server and then the server lets the client know where it put it. PUT should be used when the client specifies the location of the page.
22. What is Content-type in Rest Api
Content type specifies what type of Data your API endpoint will understand
Eg:-
- application/json
- Application/xml
- x-www-form-urlEncoded
Some common protocols used in API testing?
Many protocols are now available to be used in API testing, such as JMS, REST, HTTP, UDDI and SOAP.
What are principles of an API test design?
The five most important principles of an API test design are:
- Setup: Create objects, start services, initialize data, etc
- Execution: Steps to apply API or the scenario, including logging
- Verification: Oracles to evaluate the result of the execution
- Reporting: Pass, failed or blocked
- Clean up: Pre-test state
REST (Common Web API Testing interview questions)
What is REST?
REST (Representational State Transfer) is an architectural style for developing web services which exploit the ubiquity of HTTP protocol and uses HTTP method to define actions. It revolves around resource where every component being a resource that can be accessed through a shared interface using standard HTTP methods.
In REST architecture, a REST Server provides access to resources and REST client accesses and makes these resources available. Here, each resource is identified by URIs or global IDs, and REST uses multiple ways to represent a resource, such as text, JSON, and XML. XML and JSON are nowadays the most popular representations of resources.
What is a RESTFul Web Services?
- SOAP (Simple Object Access Protocol) – an XML-based method to expose web services.
- Web services developed in the REST style are referred to as RESTful web services. These web services use HTTP methods to implement the concept of REST architecture. A RESTful web service usually defines a URI, Uniform Resource Identifier a service, provides resource representation like JSON and a set of HTTP methods.
What is a “Resource” in REST?
REST architecture treats any content as a resource, which can be either text files, HTML pages, images, videos or dynamic business information.
REST Server gives access to resources and modifies them, where each resource is identified by URIs/ global IDs.
What is the most popular way to represent a resource in REST?
REST uses different representations to define a resource like text, JSON, and XML.
XML and JSON are the most popular representations of resources.
Which protocol is used by RESTful Web services?
RESTful web services use the HTTP protocol as a medium of communication between the client and the server.
What are some key characteristics of REST?
Key characteristics of REST are likely asked in a Web API Testing interview. So please get the answer ready in your mind with these 2 ones:
- REST is stateless, therefore the SERVER has no status (or session data)
With a well-applied REST API, the server could be restarted between two calls, since all data is transferred to the server - Web service uses POST method primarily to perform operations, while REST uses GET for accessing resources.
33. What is messaging in RESTful Web services?
RESTful web services use the HTTP protocol as a communication tool between the client and the server. The technique that when the client sends a message in the form of an HTTP Request, the server sends back the HTTP reply is called Messaging. These messages comprise message data and metadata, that is, information on the message itself.
34. What are the core components of an HTTP request?
An HTTP request contains five key elements:
- An action showing HTTP methods like GET, PUT, POST, DELETE.
- Uniform Resource Identifier (URI), which is the identifier for the resource on the server.
- HTTP Version, which indicates HTTP version, for example-HTTP v1.1.
- Request Header, which carries metadata (as key-value pairs) for the HTTP Request message. Metadata could be a client (or browser) type, format supported by the client, format of a message body format, cache settings, and so on.
- Request Body, which indicates the message content or resource representation.
35. What are the most commonly used HTTP methods supported by REST?
- GET is only used to request data from a specified resource. Get requests can be cached and bookmarked. It remains in the browser history and haS length restrictions. GET requests should never be used when dealing with sensitive data.
- POST is used to send data to a server to create/update a resource. POST requests are never cached and bookmarked and do not remain in the browser history.
- PUT replaces all current representations of the target resource with the request payload.
- DELETE removes the specified resource.
- OPTIONS is used to describe the communication options for the target resource.
- HEAD asks for a response identical to that of a GET request, but without the response body.
36. Can GET request to be used instead of PUT to create a resource?
The PUT or POST method should be used to create a resource. GET is only used to request data from a specified resource.
37. Is there any difference between PUT and POST operations?
PUT and POST operation are quite similar, except the terms of the result generated by them.
PUT operation is idempotent, so you can cache the response while the responses to POST operation are not cacheable, and if you retry the request N times, you will end up having N resources with N different URIs created on server.
In a Web API Testing interview, you should give a specific example for PUT and POST operations to make crystal clear to the interviewer. Below is an example:
Scenario: Let’s say we are designing a network application. Let’s list down few URIs and their purpose to get to know when to use POST and when to use PUT operations.
GET /device-management/devices : Get all devices
POST /device-management/devices : Create a new device
GET /device-management/devices/{id} : Get the device information identified by “id”
PUT /device-management/devices/{id} : Update the device information identified by “id”
DELETE /device-management/devices/{id} : Delete device by “id”
38. Which purpose does the OPTIONS method serve for the RESTful Web services?
The OPTIONS Method lists down all the operations of a web service supports. It creates read-only requests to the server.
39. What is URI? What is the main purpose of REST-based web services and what is its format?
URI stands for Uniform Resource Identifier. It is a string of characters designed for unambiguous identification of resources and extensibility via the URI scheme.
The purpose of a URI is to locate a resource(s) on the server hosting of the web service.
A URI’s format is <protocol>://<service-name>/<ResourceType>/<ResourceID>.
40. What is payload in RESTFul Web services?
The “payload” is the data you are interested in transporting. This is differentiated from the things that wrap the data for transport like the HTTP/S Request/Response headers, authentication, etc.
41. What is the upper limit for a payload to pass in the POST method?
<GET> appends data to the service URL. But, its size shouldn’t exceed the maximum URL length. However, <POST> doesn’t have any such limit.
So, theoretically, a user can pass unlimited data as the payload to POST method. But, if we consider a real use case, then sending POST with large payload will consume more bandwidth. It’ll take more time and present performance challenges to your server. Hence, a user should take action accordingly.
42. What is the caching mechanism?
Caching is just the practice of storing data in temporarily and retrieving data from a high-performance store (usually memory) either explicitly or implicitly.
When a caching mechanism is in place, it helps improve delivery speed by storing a copy of the asset you requested and later accessing the cached copy instead of the original.
SOAP (Common Web API Testing interview questions)
43. What are SOAP Web services?
This is one of the fundamental Web services testing questions that you must know the answer. The SOAP (Simple Object Access Protocol) is defined as an XML-based protocol. It is known for designing and developing web services as well as enabling communication between applications developed on different platforms using various programming languages over the Internet. It is both platform and language independent.
44. How does SOAP work?
SOAP is used to provide a user interface that can be accessed by the client object, and the request that it sends goes to the server, which can be accessed using the server object. The user interface creates some files or methods consisting of server object and the name of the interface to the server object. It also contains other information such as the name of the interface and methods. It uses HTTP to send the XML to the server using the POST method, which analyzes the method and sends the result to the client. The server creates more XML consisting of responses to the request of user interface using HTTP. The client can use any approach to send the XML, like the SMTP server or POP3 protocol to pass the messages or reply to queries.
45. When to use SOAP API?
Use the SOAP API to create, retrieve, update or delete records, like accounts, leads, and user-defined objects. With more than 20 different calls, you can also use the SOAP API to manage passwords, perform searches, etc. by using the SOAP API in any language that supports web services.
46. How users utilize the facilities provided by SOAP?
- PutAddress(): It is used to enter an address in the webpage and has an address instance on the SOAP call.
- PutListing(): It is used to allow the insertion of a complete XML document into the web page. It receives the XML file as an argument and transports the XML file to XML parser liaison, which reads it and inserts it into the SOAP call as a parameter.
- GetAddress(): It is used to get a query name and gets the result that best matches a query. The name is sent to the SOAP call in the form of text character string.
- GetAllListing(): It is used to return the full list in an XML format.
47. What is the major obstacle users faced when using SOAP?
When using SOAP, users often see the firewall security mechanism as the biggest obstacle. This block all the ports leaving few like HTTP port 80 and the HTTP port used by SOAP that bypasses the firewall. The technical complaint against SOAP is that it mixes the specification for message transport with the specification for message structure.
48. What are the various approaches available for developing SOAP based web services?
There are two different methods available for developing SOAP-based web services, which are explained below:
- Contract-first approach: the contract is first defined by XML and WSDL, and then Java classes are derived from the contract.
- Contract-last approach: Java classes are first defined, and then the contract is generated, which is normally the WSDL file from the Java class.
“Contract-first” method is the most popular approach.
49. What are the elements of a SOAP message structure?
It is a common XML document that contains the elements as a SOAP message
Envelope: It is an obligatory root element that translates the XML document and defines the beginning and end of the message.
Header: It is an optional item which contains information about the message being sent.
Body: It contains the XML data comprising the message being sent.
Fault: It provides the information on errors that occurred while during message processing.
50. What are the syntax rules for a SOAP message?
- Must use encoded XML
- Envelope namespace must be used
- Encoding namespace must be used
- Must not consist of a DTD reference
- Must not have XML processing instruction
51. What is the transport method in SOAP?
Application layer and transport layers of a network are used by SOAP; HTTP and SMTP are the valid protocol of the application layer used as the transport for SOAP. HTTP is more preferable, since it works well with the current Internet infrastructure, in particular with firewalls.
The SOAP requests can be sent using an HTTP GET method while the specification only contains details about HTTP POST.
52. What are some important characteristics of a SOAP envelope element?
- SOAP message has a root Envelope element
- Envelope is an obligatory part of the SOAP message.
- If an envelope includes a header element, it should not contain more than one.
- Envelope version will change if the SOAP version changes.
- The SOAP envelope is indicated by the prefix ENV and the envelope element.
- The optional SOAP encoding is also specified using a namespace and the optional encoding style element.
53. What are the major functionalities provided by the SOAP protocol class?
The SOAP protocol is used to provide simple access methods for all the applications available on the Internet, providing the following functionalities:
- Call: A class which provides the main functionality for a remote method for which a call is needed. It is used to create the call() and to specify the encoding style of the registry that will be assigned when if necessary. This call() function is used by the RPC call, which represents the options of the call object.
- Deployment Descriptor: A class used to provide the information about the SOAP services. It enables easy deployment without the need for other approaches.
- DOM2 Writer: A class that serializes and uses DOM node as XML string to provide more functionalities.
- RPC Message: A class used as the base class that calls and replies to the request submitted to the server.
- Service Manager: A class that provides, lists and then outputs all SOAP services.
54. What are the web relation functionalities provided by SOAP protocol?
- HTTPUtils: This provides the functionality of the POST method to safely meet the requirements.
- Parameter: It is an argument for an RPC call used by both the client and the server.
- Response: It is an object that represents an RPC reply from both client and server, but the result will not be displayed until after the method call.
- TCPTunnel: It is an object that provides the ability to listen on a specific port and to forward all the host and port names.
- TypeConverter: It helps to convert an object of one type into another type and this is called using the class in the form object.
55. How does the message security model allow the creation of SOAP more secure to use?
The security model includes the given security tokens. These tokens comprise digital signatures for protection and authentication of SOAP messages. Security tokens can be used to provide the bond between authentication secrets or keys and security identities. Security token uses the authentication protocols and an X.509 certificate to define the relationship between the public key and identity key. The signatures are used to verify the messages and their origin, generate knowledge to confirm the security tokens to bind the identity of a person to the identity of the originator. Security model prevents different attacks and can be used to protect the SOAP architecture.
56. What is the difference between top down & bottom up approach in SOAP Web services?
- Top down SOAP Web services include creating WSDL document to create a contract between the web service and the client, with a required code as an option. This is also known as Contract-first approach. The top-down approach is difficult to implement because classes must be written to confirm the contract defined in WSDL. One of the benefits of this method is that both client and server code can be written in parallel.
- Bottom up SOAP web services require the code to be written first and then WSDL is generated. It is also known as Contract-last approach. Since WSDL is created based on the code, bottom-up approach is easy to implement and client codes must wait for WSDL from the server side to start working.
57. What are advantages of SOAP?
- SOAP is both platform and language independent.
- SOAP separates the encoding and communications protocol from the runtime environment.
- Web service can retrieve or receive a SOAP user data from a remote service, and the source’s platform information is completely independent of each other.
- Everything can generate XML, from Perl scripts through C++ code to J2EE app servers.
- It uses XML to send and receive messages.
- It uses standard internet HTTP protocol.
- SOAP runs over HTTP; it eliminates firewall problems. When protocol HTTP is used as the protocol binding, an RPC call will be automatically assigned to an HTTP request, and the RPC response will be assigned to an HTTP reply.
- Compared to RMI, CORBA and DCOM, SOAP is very easy to use.
- SOAP acts as a protocol to move information in a distributed and decentralized environment.
- SOAP is independent of the transport protocol and can be used to coordinate different protocols.
58. What are disadvantages of SOAP?
SOAP is typically significantly slower than other types of middleware standards, including CORBA, because SOAP uses a detailed XML format. A complete understanding of the performance limitations before building applications around SOAP is hence required.
SOAP is usually limited to pooling and not to event notifications when HTTP is used for the transport. In addition, only one client can use the services of one server in typical situations.
If HTTP is used as the transport protocol, firewall latency usually occurs since the firewall analyzes the HTTP transport. This is because HTTP is also leveraged for Web browsing, and so many firewalls do not understand the difference between using HTTP within a web browser and using HTTP within SOAP.
SOAP has different support levels, depending on the supported programming language. For instance, SOAP supported in Python and PHP is not as powerful as it is in Java and .NET
59. What are the differences between SOAP and REST?
60. SOAP or Rest APIs, which method to use?
SOAP is the heavyweight choice for Web service access. It provides the following advantages when compared to REST:
- SOAP is not very easy to implement and requires more bandwidth and resources.
- SOAP message request is processed slower as compared to REST and it does not use web caching mechanism.
- WS-Security: While SOAP supports SSL (just like REST) it also supports WS-Security which adds some enterprise security features.
- WS-AtomicTransaction: Need ACID Transactions over a service, you’re going to need SOAP.
- WS-ReliableMessaging: If your application needs Asynchronous processing and a guaranteed level of reliability and security. Rest doesn’t have a standard messaging system and expects clients to deal with communication failures by retrying.
- If the security is a major concern and the resources are not limited then we should use SOAP web services. Like if we are creating a web service for payment gateways, financial and telecommunication related work, then we should go with SOAP as here high security is needed.
REST is easier to use for the most part and is more flexible. It has the following advantages when compared to SOAP:
- Since REST uses standard HTTP, it is much simpler.
- REST is easier to implement, requires less bandwidth and resources.
- REST permits many different data formats whereas SOAP only permits XML.
- REST allows better support for browser clients due to its support for JSON.
- REST has better performance and scalability. REST reads can be cached, SOAP based reads cannot be cached.
- If security is not a major concern and we have limited resources. Or we want to create an API that will be easily used by other developers publicly then we should go with REST.
- If we need Stateless CRUD operations then go with REST.
- REST is commonly used in social media, web chat, mobile services and Public APIs like Google Maps.
- RESTful service returns various MediaTypes for the same resource, depending on the request header parameter “Accept” as application/xml or application/json for POST and /user/1234.json or GET /user/1234.xml for GET.
- REST services are meant to be called by the client-side application and not the end user directly.
- ST in REST comes from State Transfer. You transfer the state around instead of having the server store it, this makes REST services scalable.
61. What are the factors that help to decide which style of Web services – SOAP or REST – to use?
Generally, REST is preferred due to its simplicity, performance, scalability, and support for multiple data formats.
However, SOAP is favorable to use where service requires an advanced level of security and transactional reliability.
But you can read the following facts before opting for any of the styles.
- Does the service expose data or business logic? REST is commonly used for exposing data while SOAP for logic.
- The requirement from clients or providers for a formal contract. SOAP can provide contract via WSDL.
- Support multiple data formats.
- Support for AJAX calls. REST can apply the XMLHttpRequest.
- Synchronous and asynchronous calls. SOAP enables both synchronous/ asynchronous operations whereas REST has built-in support for synchronous.
- Stateless or Stateful calls. REST is suited for stateless operations.
- Security. SOAP provides a high level of security.
- Transaction support. SOAP is good at transaction management.
- Limited bandwidth. SOAP has a lot of overhead when sending/receiving packets since it’s XML based, requires a SOAP header. However, REST requires less bandwidth to send requests to the server. Its messages are mostly built using JSON.
- Ease of use. REST based application is easy to implement, test, and maintain.
End point: Address where API is hosted on the Server.
HTTP methods which are commonly used to communicate with Rest API’s are
GET, POST, PUT, and DELETE
GET- The GET method is used to extract information from the given server using a given URI. While using GET request, it should only extract data and should have no other effect on the data. No Payload/Body required
How to send input data in GET?
Ans: Using Query Parameters
POST- A POST request is used to send data to the server, for example, customer information, file upload, etc. using HTML forms.
How to send input data in POST?
Ans: Using Form Parameters /Body Payload
PUT- Replaces all current representations of the target resource with the uploaded content.
DELETE- Removes all current representations of the target resource given by a URI.
Resources:
Resources represent API/Collection which can be accessed from the Server
Google.com/maps
google.com/search
google.com/images
Path Parameters:
Path parameters are variable parts of a URL path. They are typically used to point to a specific resource within a collection, such as a user identified by ID
https://www.google.com/Images/1123343
https://www.google.com/docs/1123343
Query Parameters:
Query Parameter is used to sort/filter the resources.
Query Parameters are identified with?””
https://amazon.com/orders?sort_by=2/20/2020
Headers/Cookies:
Headers represent the meta-data associated with the API request and response. In layman terms, we were sending Additional details to API to process our request.
Example : Authorization details
End Point Request URL can be constructed as below
Base URL/resource/(Query/Path)Parameters