TrustedRequest for bamboo REST call returns 401 error code

I am trying to execute a bamboo REST call to clone a plan via TrustedRequest for a bamboo plugin, but I get 401 status code.

Is TrustedRequest not supported by Bamboo ?

Following is the code I am working with

final String baseUrl = applicationProperties.getBaseUrl(UrlMode.CANONICAL) ;
     final String url = baseUrl+
           "/rest/api/latest/clone/"+"P1-PLAN1:P1CLONE-PLAN1";

     String hostString = "localhost";
     try {
        URL hostUrl = new URL(baseUrl);
        hostString = hostUrl.getHost();
     } catch (MalformedURLException e) {
        LOG.error("Error trying to get host from the base url.\n\n" + e);
     }

     try {
        //here requestFactory is referencing the instance of com.atlassian.sal.bamboo.trusted.BambooHttpClientTrustedRequestFactory@7cb03893
        //and request is referencing the instance of com.atlassian.sal.core.net.HttpClientTrustedRequest@271a6774
        TrustedRequest request =
           requestFactory.createTrustedRequest(MethodType.PUT, url);
        // add machine name
        request.addTrustedTokenAuthentication(hostString);

        request.execute(new ResponseHandler<Response>() {

           @Override
           public void handle(
              final Response response) throws ResponseException {
              if (response.getStatusCode() != HttpStatus.SC_OK) {
                 LOG.info("REST call " + url + " response text - " +
                       response.getResponseBodyAsString());
              }
           }
        });
     } catch (ResponseException e) {
        LOG.error("Exception calling bamboo plan clone REST API:", e);
     }

The response body text I receive is

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<status>
  <status-code>401</status-code>
         <message>Client must be authenticated to access this resource.
         </message>
  </status>"

I am using Atlassian SDK 6.2.14 with AMPS version 6.2.11. The bamboo version I am working with is 6.5.1