1. Home
  2. OpKey Help
  3. 14. Working with Service Repository (Testing web services)
  4. 14.2 Adding Rest Service

14.2 Adding Rest Service

Quick Start Screencast:

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.

Was this article helpful to you? Yes 2 No