Introduction

This page demonstrates how to use the ATS REST client


Simple example

Let's have a look at this example:

import com.axway.ats.action.rest.RestClient;
import com.axway.ats.action.rest.RestMediaType;
import com.axway.ats.action.rest.RestResponse;

@Test
public void restOperations() {

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

    // set some headers or query parameters if needed
    client.setResponseMediaType( RestMediaType.APPLICATION_JSON )
          .addRequestParameter( "firstName", USER_FIRST_NAME )
          .addRequestParameter( "lastName", USER_LAST_NAME );

    // execute some HTTP method
    RestResponse 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

 


Working with JSON body

Here you can see how to work with a JSON body when sending a request or receiving a response

 


Working with XML body

Here you can see how to work with a XML body when sending a request or receiving a response

 


Configuring the REST client

You need more logs from the client or need connected over SSL. Or may by you need to change the way we send java objects over the channel.

Here are the details.

 


Back to parent page

Go to Table of Contents