3 Replies Latest reply on Feb 7, 2018 9:50 PM by LaxmiRagi

    Create Transient RESTHost and RESTOperation.

    LaxmiRagi Novice


      I am facing problem while creating transient RESThost and RestOperation.

      Execute a transient RESTOperation for a transient RESTHost - Samples - VMware {code}

      While executing above reference code as it is below error occurs

      Unable to create object : RESTHost : com.vmware.o11n.plugin.rest.RESTHost

      My Inputs:

      URL : https://myhost/myapp/api/

      user: username

      password : pass2345


      Please help me to understand where am i doing mistake.


      Thnak you.

        • 1. Re: Create Transient RESTHost and RESTOperation.
          eoinbyrne Hot Shot

          When I used the Transient RESTHost mechanism I had to use an existing inventory RESTHost as the template





          var myURL = "https://myhost/myapp/api";
          var transientRESTHost = RESTHostManager.createTransientHostFrom(inventoryRESTHost);
          transientRESTHost.url = myURL;


          The class document for that method - vRO API Explorer by Dr Ruurd and Flores of ITQ - shows that an existing RESTHost instance is used as a template / prototype



          • 2. Re: Create Transient RESTHost and RESTOperation.
            philippbck Novice

            // Create REST Request

            var restHost = RESTHostManager.createHost("dynamicRequest");

            httpRestHost = RESTHostManager.createTransientHostFrom(restHost);

            httpRestHost.operationTimeout = 60;

            httpRestHost.connectionTimeout = 30;

            httpRestHost.hostVerification = false;

            httpRestHost.url = requestHostUrl;


            var request = httpRestHost.createRequest(requestMethod, requestTemplateUrl, requestBody);


            //  Basic authentication:

            var authParams = ['Shared Session', username, password];

            var authenticationObject = RESTAuthenticationManager.createAuthentication('Basic', authParams);

            httpRestHost.authentication = authenticationObject;


            // Set Content Type

            request.contentType = requestContentType;

            if (closeConnection == true){

            request.setHeader("Connection", "Close")


            // Execute REST Request

            System.log("REST Request: " + requestMethod + " " + request.fullUrl);

            var response = request.execute();


            // Output

            statusCodeAttribute = response.statusCode;

            System.log("REST Response Status Code: " + statusCodeAttribute);

            responseAsString = response.contentAsString;

            if(logResponseOutput == true){

            System.log("REST Response Content: " + responseAsString);


            1 person found this helpful
            • 3. Re: Create Transient RESTHost and RESTOperation.
              LaxmiRagi Novice

              Thank you so much its working...!