Introduction

This page introduces briefly how to use the ATS HTTP client.

 


Simple example

Let's have a look at this example:

import com.axway.ats.action.http.HttpClient;
import com.axway.ats.action.http.HttpResponse;

@Test
public void httpOperations() {

    // Instantiate the HTTP client by providing the remote URL
    HttpClient client = new HttpClient( SERVER_BASE_REST_URL + "demo/gethome" );

    // execute some HTTP method, set some headers or query parameters if needed
    client.addRequestParameter( "firstName", USER_FIRST_NAME );
    client.addRequestParameter( "lastName", USER_LAST_NAME );
    HttpResponse response = client.get();

    // verify we received the expected status code
    assertEquals( 200, response.getStatusCode() );

    // read the response body
    String responseBody = response.getBodyAsString();
}

As you can see we first point to the target HTTP resource we intend to work with, then we provide some request data if needed(like headers or query parameters) and then we execute some of the supported HTTP methods. Finally we extract the response content.

 


Supported HTTP methods

Here is the list

 


Working with the request

Here are the details

 


Working with the response

Here are the details

 


Logging

Here you can see how to inspect the communication if needed

 


Back to parent page

Go to Table of Contents