Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Creating Requests 
1.1.
Create Requests from Toolbar 
1.2.
Adding from Specification 
1.3.
Using Existing Operations 
1.4.
Recording Requests
2.
Creating Responses
2.1.
Add Responses
2.2.
Set Contents of Response 
2.3.
Set Custom Headers
3.
Data Source Data and Virtual Service Properties 
4.
Frequently Asked Questions
4.1.
What is ReadyAPI?
4.2.
What is an API request?
4.3.
What is an API response?
5.
Conclusion 
Last Updated: Mar 27, 2024

Creating Requests and Responses in Ready API

Creating Requests 

Adding requests to a virtual API can be different for REST, SOAP, JMS and JDBC virtual services. Here are some methods to create requests: 

Ready API


Create Requests from Toolbar 

  1.  To open the virtual service editor, select your virtual service from the panel on the left.
  2. Click on the desired virtual service in the virtual service editor:
  • JMS route (JMS virtual service)
  • Operation (SOAP virtual service)
  • Action (REST virtual service)

3. After selecting the virtual service type, the dialogue box opens, where you can specify the properties of the new request.
 

Adding from Specification 

This method can be used for REST and SOAP only.

If you have a Swagger, OpenAPI, WSDL, or WADL specification added to your ReadyAPI project, you can create virtual requests directly through that specification following the steps below:
 

  1. Select Generate Virtual Service from the Navigator panel on the left.
  2. In the dialogue that opens:
  • Select the operations that are to be added to the service
  • Select Add to existing virtual service 
  • Choose your required virtual service in the drop-down list, Virtual Service
  • Click OK

 

Using Existing Operations 

Valid for REST, JMS and JDBC only.

Clone the existing operations using previously defined operations as the base. This is time effective and quick. Follow the steps below:

  1. In the virtual service editor, click Duplicate VirtAction after finding the desired base operation. This new operation is added to the end of the operation list. 
step1
  1. From the list, select the operation name, and change the resource path in the editor on the right. I the resource path is kept, you will have two virtual operations for the same resource. The virtual service will use the operation it finds earlier in the list.
step2


Recording Requests

This is used for REST, SOAP and JDBC only. 

If you want to add requests based on a real API, you need to configure your virtual service to record non-virt operations and use recordings.
 

Creating Responses

We will now learn how to create responses for virtual requests on a virtual API.
 

Add Responses

One request may have multiple responses. To virtualise an API, responses must be created to handle virtual requests. The dispatch settings are used to select a response for the reply. 

Click add response to create a response for the desired request in the virtual service editor. ReadyAPI creates an empty response. 

add response

Set Contents of Response 

Contents of the response need to be added after the creation of the response. The contents and editor information depend on the virtual service type: REST, JMS, and SOAP use different response properties:
 

  • HTTP status code field is set for REST and SOAP services. This specifies the code that will be returned to the client, which is used to determine if the request was successful.
set contents of response for REST and SOAP
  • For JMS services, response contents are specified in the Edit fields.
set contents of response for JMS
  • Results section is used to specify the contents of the JDBC virtual services. The number of queries modified is displayed in the section.
response 1

  •  

Set Custom Headers

Custom headers can be set to responses in the Headers section. These custom headers can include data of the data source and visual service properties.

Set Custom Headers

 

Data Source Data and Virtual Service Properties 

Response data can be customised by inserting data source data and virtual service properties. This enables the creation of similar responses with the same structure but different data.
 

Frequently Asked Questions

What is ReadyAPI?

ReadyAPI is a ready-to-use API testing platform. It is a no-code platform that enables users to easily create requests and responses to virtual APIs and test against functional tests.
 

What is an API request?

An API request is a client sending the server a request. This request asks the API to reciprocate with the required information or service.
 

What is an API response?

An API response is fetched to a request generated by the client. It contains the answer to the request doubt, or suitable information is fetched and given to the client.
 

Conclusion 

In this blog, we walked through the basic steps to generate requests and responses in ReadyAPI. We saw the various forms and how to formulate requests and responses for them. Additionally, join our platform Coding Ninjas Studio to get an insight into basic computer fundamentals like DBMSDSACompetitive ProgrammingPythonJava, etc. Share and upvote this blog if you find it helpful to help fellow ninjas get acquainted with it and help them grow. Happy Coding!!

 

thank you



 

Live masterclass