Adding a REST Service in Opkey


Testing REST APIs is essential for web application functionality. REST APIs, based on REST architecture, support various data formats, making them widely used for flexible data transfer in web apps. 

 

Each test case generates diverse API requests, evaluating responses to ensure accurate and secure functionality. This provides vital insights for development and maintenance. 


In this article, we will create a REST API method and call it in a test case.  

 

Log in to the Opkey portal and select the project to work on. 


In the project workspace, click on Create New and select a new Service Repository to be created. 



 

 


A new Service Repository is created. Rename the node and click on the Rest API Test button. 

 

 



A new Service Repository file is created. Rename it and add the required URL in the Service URI section.


 


Based on the provided Service URI a new method is generated. There are various methods such as GET, POST, PUT, DELETE, and PATCH available through which you can retrieve data. 


 


We will proceed with the GET method. Click on the Edit button to add the resource from the portal.





Here we are using https://reqres.in/


Go to the portal and select the Get Method. Copy the Resource and paste it in the Pop-up box.



You can now see the Resource data. Click on the Run button. 



This service will fetch the user list.  


We will use the code to fetch email, first name, and last name.


 


Create a function library and add the created Service Repository.





The output we get is in JSON format. Add another step to separate the required values from the JSON output. For that let’s add the keyword GetValueFromJson.


 


Use the output of one step as an input of the next step.

 



Map the output components of one step to the input components of another step. 

 

 

 

To get value from JSON keyword inside input data. Next, we will provide the Json path value to the GetValue FromJson keyword to help us get the first name of the first user. 


 

 

With the same method, we can fetch the last name and email address of the user. 

We have added three keywords here with the values and Saved the test case.  


 

 

Click on the Run button and execute the test case. 


 

 

Enter the details of the Session Name, Build Name, and execution agent on the Local Execution Wizard. Click on Finish. 





On the live logs, View the first name, last name, and email address of the user being added. 


 



Now let’s view the output generated.

The first keyword will generate the first name of the user. 



 




The second keyword will generate the last name of the user. 


 




Similarly, the last keyword will generate the email address of the user. 


  

This is how REST API Testing works in Opkey. 

Read the article on SOAP API Testing by clicking Here

 
 





Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article