// The first Request's body
String body1 = "The request body of the manually configured Request";
// Make a new POST Request.
Request manualRequest = new Request(config, "subpath", HttpMethod.POST); // construct the Request
// Configure the request
manualRequest.setBody(body1); // set the request body to send to the server
manualRequest.addObserver(requestObserver); // Add the requestObserver to the request's set of Observers
// Send the request!
manualRequest.send();
// This should print first.
System.out.println("This was printed after sending the manually created Request!");
/* ~~~ Below shows how to send a request using the Network. ~~~ */
// Set the default network configuration. This step will likely already have been completed by Janeway, so you don't have to do it.
Network.getInstance().setDefaultNetworkConfiguration(config);
// The first Request's body
String body2 = "The request body of the Request created by Network";
// Make a new POST Request with the default network configuration.
Request networkRequest = Network.getInstance().makeRequest("subpath", HttpMethod.POST);
// Configure the request
networkRequest.setBody(body2); // set the request body to send to the server
networkRequest.addObserver(requestObserver); // Add the requestObserver to the request's set of Observers
// Send the request!
networkRequest.send();
// This should print first.
System.out.println("This was printed after sending the Request created using Network!");
}