Working with REST Requests

How to Make REST Requests


Everything in the RESTful architecture is about resources. A resource is an object with its own associated data. Resources have relationships with other resources and a set of methods or verbs to operate between these resources. Then you can have a collection of resources which can interact as a collection with one or more resources or collections. When you want to identify a certain resource, you make a request.


REST is a simple concept because it follows a basic language of HTTP 1.1 hypertext transfer that the entire Web understands. Each request has a specific HTTP verb, or method, in the request header. This is the first all caps word in the request header. Your basic REST HTTP requests are: POST, GET, PUT, and DELETE. Other options can be used however, they are not used as often. Let’s look at an example from the Swagger Pet Store API:


  • Sending a GET request to /pet/{petId} would retrieve pets with a specified ID from the database.
  • Sending a POST request to /pet/{petId}/uploadImage would add a new image of the pet.
  • Sending a PUT request to /pet/{petId} would update the attributes of an existing pet, identified by a specified id.
  • Sending a DELETE request to /pet/{petId} would delete a specified pet.


If you’d like to learn more about REST request methods, please visit our resource page on API Request Methods.


REST Response Formatting


There aren’t any rules about which format a REST response should be in. Most APIs return XML or other standard formats however, the choice is really yours. Tools have their own way of showing you responses, but SoapUI being a very user friendly tool gives you the outline view which parses the responses for you and makes it very easy for you to read and edit JSON and XML. In SoapUI, you have the option to choose from a variety of options. Those options are:

  • XML
  • JSON
  • HTML
  • RAW
  • Outline (Pro only)
  • Overview (Pro only)


You can go into more detail about what these formats look like in the example below.


If you’d like a more detailed guide to working with RESTful APIs, download our E-book: REST 101: The Beginner's Guide to Using and Testing RESTful APIs

To get started with this tutorial download SoapUI Pro now!


REST Requests in SoapUI

Double-clicking a REST Request in the navigator opens the REST Request editor window:

REST Request Editor

Just like the corresponding SOAP Request Editor, this window has the following components:

  • A toolbar at the top with standard actions and the endpoint dropdown for easily changing the service endpoint
  • A Request Editor to the left with corresponding editor views along the left border and editor tabs at the bottom
  • A Response Editor to the right with corresponding editor views along the left border and editor tabs at the bottom


Let’s have a look at the request and response editor views and tabs.

1. Request Editor Views

The Request editor has the following editor views available along the left border:

  • Request (shown above): shows a tabular view of all the parameters defined for the Request, these are the aggregate of the containing Method and its Resource and any parent Resources available. Table also contains the parameter style and level (RESOURCE or METHOD) at which parameter exists. If a parameter is added at RESOURCE level then it is used by all requests under that resource but if the parameter is at METHOD level then it will used only by the requests under that method. REST parameter details are available here

    You can Add/edit/remove the parameters from the request editor. A new parameter is added at RESOURCE level by default but level can be changed by selecting other value in the drop down and it will propagate to all the requests in navigation tree of the level. A good thing to keep in mind is that this will affect other requests also in the navigation tree since parameter level is either RESOURCE or METHOD. The parameter value entered/edited in the request editor is local to request only and hence is not propagated to other requests in the navigation tree. Add your desired parameter and corresponding values in this table (property-expansion is supported also)

    If the Method uses an HTTP Verb that sends a request body (POST or PUT), a corresponding editor for the message content is made available under the table of parameters:

    REST Request Editor: Request View

    If the Method is linked to a XML Schema definition (in an imported WADL), the recreate button can be used to generate a new message in accordance with the schema. The "Media Type" drop-down provides a number of standard media types for the request body, but you are free to enter any other value instead.

    If you want to insert the message body from a file instead then leave the editor empty and add a single attachment with the same content-type as the set media-type for the message; SoapUI will insert the contents of the file into the message body instead of attaching it as a MIME attachment (described below).

    If you want to simulate the submit of an HTML Form using the " multipart/form-data” content-type you can specify individual parameter values to be read from a file by setting their value to “file:” which will insert the file into the outgoing request.
  • RAW: just as for SOAP Requests this shows the Raw bytes sent for the last request. After submitting a request it will contain something like:

    REST Request Editor: Raw Request View
  • Outline (soapUI Pro only): Shows a tree-view over the message body (only applicable for POST and PUT requests), for example:

    Request: Request Message Content Field

    in the message body will result in the following editor:

    Request: Request Outline View

    For complex messages this can be easier to work with than the Raw XML view if an XML Schema is not defined (which would allow you to use the Form editor instead).
  • Form (SoapUI Pro only): Renders a nicer input form for both the requests parameters and its eventual message body schema. For example the imported Google Maps API method gets rendered as follows:

    REST Request Editor: Form View

    As you can see this provides some additional benefits over the simple table-based editor (validation, drop-downs, etc).

Request Message Tabs

A number of tabs are available along the bottom of the Request Parameters View; let’s have a look at them in order to see how they can be used:

  • Auth: Allows you to specify HTTP Authentication information:

    REST Request: Auth Tab

    Specifying username and password will allow soapUI to authenticate with the service using Basic HTTP Authentication (if challenged by the server). If you want soapUI to send credentials directly without a challenge, then select the “Preemptive Authentication” option in the global HTTP Preferences. In this case you can see the credentials in the Raw message tab after sending:

    REST Request: Auth in Raw View

    Specifying a value in the Domain fields also allows soapUI to authenticate with NTLMv1 servers (NTLMv2 is not directly supported but can be accessed by using a third party tool like...).
  • Headers: Allows you to add arbitrary HTTP Headers you might want to include with your request, for example

    REST Request: Headers tab

    results in

    REST Request: HTTP Header param in Raw view

    in the Raw request tab.
  • Attachments: Contains any files that should be attached to the request as MIME attachments. If you want to associate the content of a file with any of the parameters when simulating a HTML multipart/form-data form then specify that parameters value as “file:”. For example:

    REST Request: Attachments View

    Here you can see the request has two parameters both specifying file. The first just refers to a file in the file system (“hermes.log”), and the second refers to an attachment (“error.log”).Setting the media-type to multipart/form-data and posting the query string will send the request as if it were a HTML Form with corresponding File input fields.
  • Representations: Shows the defined request representations for the underlying REST Method:

    REST Request: Representations Tab

That’s it for the request editor; let’s have a look at the response editor as well.

2. Response Message Views

The response editor contains several views for visualizing different types of responses;

  • XML: shows the current response in XML format. SoapUI will attempt to convert HTMLresponses to XML so they can be used in property transfers and scripts just like any other response messages in your functional tests.--> For example, here comes a HTML response rendered as XML:

    REST Request Editor: Response XML View

  • JSON: shows a nicely-formatted rendering of the returned JSON response (if applicable):

    REST Request Editor: Response JSON View

  • HTML: renders the contents of an HTML response (if applicable), for example if we create a REST service for the SoapUI website and define the root page (“index.html”) as a resource with a GET method we can see the results:

    REST Request Editor: Response HTML View
  • You can click in the page just as usual, pages that are shown in a new window will be opened with the current system browser instead.

    Please note that the Browser component used by soapUI does not work on all platforms, in which case you will get a “Browser Component Disabled” message instead.
  • Raw: shows the raw bytes received for the response. For the above HTML page this contains:

    REST Request Editor: Response Raw HTML View
  • Outline (soapUI Pro): A tree-view over the contents of the XML View. Here you can see the XML version of the above JSON response:

    REST Request Editor: Response Outline View
  • Overview (soapUI Pro): an easy to read view of the XML response message, here once again for the JSON response above:

    REST Request Editor: Response Overview View

    (URLs are marked in blue and clickable, they will be opened in the system browser)

The corresponding editor tabs for a response are:

  • Headers: shows all HTTP Headers received with the response, once again for the JSON response above:

    REST Request Editor: Response HTTP Headers
  • Attachments: contains all MIME attachments returned by the response
  • SSL-Info: shows detailed information on the certificate and certificate chain used if the request was sent over an SSL connectio
  • Representations: shows the currently defined Response Representations for the containing method:

    REST Request Editor: Response Representations Tab
  • Schema: allows for generation of an XML Schema for the returned response messages, read more on Schema Inference in soapUI at...
  • Table: Shows a tabular view of the XML response message based on the currently highlighted node in the XML or Outline editor. For example if we open the JSON response in the XML editor and place the cursor in the first element we get:

    REST Request Editor: Response Table Inspector

    soapUI has generated a table of the XML content related to the selected node, you can now get a much better overview of the contents of the message.
  • XML: Useful when you are in the Outline view, this tab displays the XML for the currently selected node:

    REST Request Editor: Response XML Tab

    As you can see the XML for the selected “e” element is displayed, and its XPath location is displayed just on top of the XML view.