Using Runscope with Codenvy

Use this Codenvy Factory to instantly start working with a sample Runscope API project:

This tutorial will explain the details of integrating the Runscope API into Codenvy. Runscope is an automated testing and API traffic inspection tool allowing you to create automated tests for your customer application and also monitoring traffic flow within your customer application URL. Runscope API provides the programmatic access to the data in your Runscope account thereby allowing you to retrieve information about the automated tests and traffic flow. The explanation has been done with a very basic Java servlet project that makes use of the Runscope API to explain some basic features provided by the API.

Register With Runscope

Before proceeding to the creation of the Java project, please register at with your email id:


While registering, you will need to create an application which will then generate the API keys which can be found under your account:


You can get more information about the Runscope API at There are different subsections providing information about automated testing, traffic inspection and various methods available in the API to retrieve information about these from your Runscope account. Each API method subsection at will detail the request URL required to invoke the specific API method that you can use in your integration process and the list of input parameters and the response fields. As can be seen from the documentation, Runscope uses OAuth mechanism to derive the access token for authentication to use the API. The access token is derived using the API keys and so you will need to derive an access token within your application to start using the API.
For development purposes, Runscope generates an access token along with the API keys when you create your application and this access token is available under your account:


You can click on the ‘Try it in the Request Editor’ button to generate the API method request URLs and parameters that you want to use in your application:


After creating your Runscope account, you can see your account dashboard at This will give you a view of all the tests and traffic flow within your runscope account and will also allow you to create tests and activate traffic flow for your application using the process defined in the documentation. You can access the account dashboard information programmatically using the API methods:


Create a Project

Now, login to your Codenvy workspace and create a WAR project named as ‘RunscopeSample’. This will have the following structure:

Create pom.xml File

To make use of the Runscope API through HttpClient as a servlet, please update the pom.xml to include the HttpClient and Java EE Web API jars and the servletapi jar into your project as Maven dependencies:

      <name>Maven Repository Switchboard</name>

This will include these jars in your project as follows:

Create Java Class

Now create a Java servlet class named that will talk to the Runscope API with the Http request URL and input parameters(obtained from the Request Editor or documentation) to request all the messages available in your bucket – test runs as well as website traffic flows(the same information which is available in your account dashboard) and then get a Http response back with the response header and the response body which will be then displayed on the browser through a JSP. All this is done inside the method doGet() in the sample source Java class.

   protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

        StringBuffer sb = null;
        try {
            String getURL = "";
            HttpGet req = new HttpGet(getURL);
            req.addHeader("Authorization", "Bearer sdfresrfsefrsefsd35345345345");
            HttpResponse res = client.execute(req);
            HttpEntity entity = res.getEntity();
            String responseString = new BasicResponseHandler().handleResponse(res);
            if (entity != null) {

            sb = new StringBuffer("<br/>Simple GET request to url : "+ getURL +"<br/><br/>");
            sb.append("*** Request headers ***").append("<br/>");

            Header[] requestHeaders = req.getAllHeaders();
            for (Header header : requestHeaders) {

            sb.append("*** Response headers ***").append("<br/>");

            Header[] headers = res.getAllHeaders();
            for (Header header : headers) {
            sb.append("*** Response Body ***").append("<br/>");
        } catch (Exception ex) {
            sb = new StringBuffer(ex.toString());

        request.setAttribute("data", sb.toString());
        RequestDispatcher rd = request.getRequestDispatcher("/success.jsp");
        rd.forward(request, response);

Create index.jsp File

Your Codenvy project will have an index.jsp which will invoke the Servlet class -


Create success.jsp File

Your Codenvy project will have a success.jsp which will be invoked from the RunscopeServlet class to display the response on the browser -

      <p>Data : <br/><%=request.getAttribute("data") %></p>

Create web.xml File

The servlet mapping ‘/hello’ is defined in the web.xml as follows –

  <display-name>Runscope Servlet App</display-name>


Now you build and run your Codenvy project and the Http response will be displayed in the browser:


In a similar way, you can use other available API methods and integrate the Runscope API into your application to meet your application needs.