REST stands for REpresentational State Transfer and it’s an advanced way of using web services. SOAP allows you to exchange/transfer data in the form of XML during web service communication while REST allows you various formats for transferring data in web communication. REST is a new technology that is preferred over SOAP. Now, OpKey is empowered by REST web service features!

Create a Service Repository File and click on ‘Add REST Service’ icon. Further, enter Service URI & select Authentication Type as shown below:

Just after entering service URI, a new method gets added automatically and URI gets broken down into Endpoint, Resource, and QueryString. You can enter static URI or select URI from the global variable. It creates a REST file to which with REST URI and Authentication Type fields.

Authentication Types: 

OpKey allows its users to test web services that need different authentication types. Here are the OpKey supported authentication types:

(For details about the Authentication of web services, kindly refer: Authentication)

REST URI is a mandatory field that can be filled by using Static or Global Variable.

13.2.1 Add Rest Method

While creating a new Rest Service, a method is created automatically. Furthermore, you can also add additional methods by clicking on the Add Method icon to add different methods (GET, POST, PUT, DELETE) and also add Parameters as Query String, Request Header and Request Body to perform different REST operations.

When you enter a valid URI for using web services through REST service, your URI gets broken into three parts: EndPoint, Resource, and QueryString. You also need to select the corresponding method (GET, POST, PUT or DELETE) from the given dropdown list. You can edit parameters of QueryString as per your need.

Important Points

  • You must enter a valid URI for using web services.
  • REST Service contains four methods: GET, POST, PUT and DELETE methods which can be used as per requirement.
  • The GET method is used for getting back the requested data in the form of response. While using the Get method, you can directly execute web services of given URI by using command.
  • Only EndPoint & Authentication Type is shown on RestService Page under Service URI and Authentication pane. This page allows you to rename EndPoint of entered URI which will reflect in all associated methods under that Rest Service.
  • POST & PUT methods are used to Create and Update/Replace resources.
  • The Delete method is used to deleting given entry from the intended resource.
  • When you use other methods (POST, PUT & DELETE), other than GET; Run command gets disabled.
  • Entered URI automatically gets divided into two parts: EndPoint and QueryString. Endpoint is an essential part of URI but QueryString may either be present or absent and it depends on web service URI.

  • QueryString, Placeholder, RequestHeader and RequestBody are parameter's group. Order, Sort & Site are sub-parameters of QueryString which can be easily edited. Entered URI may contain such parameters but it's not compulsory that every entered URI must contain such parameters. In fact, it depends on that URI.
  • EndPoint, Resource (including Placeholder) and QueryString are parts of URI. But, RequestHeader & RequestBody are part of request.
  • You can add new parameters in given parameters group (QueryString, Placeholder, RequestHeader and RequestBody).
  • QueryString is the part of a uniform resource locator (URL) containing data and it commonly includes fields added to a base URI by a Web browser; for example as part of an HTML form. The query string is composed of a series of field-value pairs.
  • HTTPHeader is the component of the header section of request and response messages in the Hypertext Transfer Protocol (HTTP).
  • HTTPBody is similar to the Message Body which transmits data in an HTTP transaction immediately following the headers.
  • The placeholder describes the expected value of an input field (e.g. a sample value or a short description of the expected format). The placeholder attribute of a service URI works with the following input types: text, search, url, tel, email, and password.
  • New parameter groups cannot be added i.e. you can add only new parameters under given parameters group.
  • Placeholder is a dynamic part of the Resource. You can add placeholder in resource part using curly braces ({}). To change/edit Placeholder parameter, click on Edit Resource button ().
  • Editing Tools are used to add, delete, move up & move down parameters respectively. You should be familiar about the impact that may be resulted due to adding, deleting, moving up or moving down parameter(s).
  • Before running execution, you further need to choose Output type from the given dropdown list (HttpBody, HttpRaw, HttpHeader or HttpStatus).

Output Type:

  • HttpBody: Choose HttpBody when you need body part of the response.
  • HttpRaw: Choose HttpRaw when you need Raw data part of the response.
  • HttpHeader: When you choose HttpHeader as Output Type, a new corresponding dropdown list of Header Content appears. You need to choose a Header Content Type from dropdown list and enter content key in editable area which is required in the result output.
  • HttpStatus: Choose HttpStatus when you need response status as an output in result.


Executing Web Services:


14.4.1 Executing Web Services (REST) using GET Method

  • Click on Add REST Service and provide URI.
  • Add Rest Method in Service.
  • Select GET http method.
  • Now, click on Run command button to execute web service of given URI.

10

  • The response contains two types of data: Response Data & Raw Data as shown in below screenshot.

11

Authentication Types: 

OpKey allows its users to test web services that need different authentication types. Here are the OpKey supported authentication types:

(For details about the authentication and its types, please refer: Authentication of Web Services)

 14.4.2 Executing Web Services (REST) using POST Method

  • Select POST http method.
  • Add required parameters.

Further, In parameters section, enter name (in Name column), path of the desired file (in Default Value column) under RequestBody parameter and check Is Argument, Is File check boxes. You also need to enter Name in RequestBody, choose Content Type corresponding to the selected file. Further, select nocheck and check ‘Is Argument’ check box under RequestHeader parameter so that you can put your file over desired application without facing any security related issue.

12

Now, you can execute this REST web service with Post method by using it into Test Case or Function Library. Here, we are executing given web service URI through Test Case. Click on Add Step to add new step and map it with the corresponding Service Repository (SR) file. Further, click on Run to execute it.

13

 

 

14.4.3 Executing Web Services (REST) using PUT Method

  • Create a Service Repository File
  • Click on Add REST Service
  • Enter web service URI and select Authentication type
  • Add PUT Method and select authentication type.
  • Enter authentication credentials corresponding to your Jira.

notePUT method is similar to the POST method which is used for updating given entries.

 

14

Enter Web Service URI, select Authentication Type, and enter Authentication credentials (Username & Password) of desired web application on which entry has to be updated with PUT method.

15

Add method by clicking on icon from tool menu & select PUT method from the dropdown list and then enter URI of desired web application. In parameters section, left name 'Blank' (in Name column), path of the desired file (in Default Value column) under RequestBody parameter and check Is Argument, Is File checkboxes. You also need to choose Content Type corresponding to the selected file. Further, select Token as nocheck and check Is Argument checkbox under RequestHeader parameter so that you can put your file over web application without facing any security related issue.

 

noteHere, Name is left as Blank because we just need to pick text from the selected text file by using PUT Method, unlike posting/uploading whole file in POST method.

 

16

Now, we need to execute this REST web service by using it into Test Case or Function Library. Here, we are executing given web service URI through Test Case. Click on Add Step to add new step and map it with the corresponding Service Repository (SR) file. Further, click on Run to execute it.

14.4.4 Executing Web Services (REST) using DELETE Method

  • Create a Service Repository File
  • Click on Add REST Service
  • Enter web service URI and select Authentication type
  • Add DELETE Method and select authentication type
  • Enter authentication credentials corresponding to your Jira

17

noteDELETE Method is used to delete selected Jira issue. Here, we will delete an object from the list of objects by using DELETE Method in REST WebService.

 

18

Add method by clicking on icon from tool menu. Here, you need to select DELETE method from the dropdown list and enter URI of Jira. In parameters section, enter Token as nocheck and check Is Argument checkbox under RequestHeader parameter. Under RequestBody parameter, you don't need to enter any value because we are trying to delete an issue rather than post or put any value as well.

Now, execute this REST web service by using it into Test Case or Function Library. Here, we are executing given web service URI through Test Case. Click on Add Step to add new step and map it with the corresponding Service Repository (SR) file. Further, click on Run to execute it.

19