Quantcast
Channel: VMware Communities : Discussion List - vRealize Orchestrator
Viewing all articles
Browse latest Browse all 6251

Help required for creating a action

$
0
0

I am planning to create a action which will basically login to NSX using REST API  and then create a array which will store the value for transportzone.

 

I created a workflow with REST api for testing and it worked.

 

Now i am trying to create the action using the same working code.

 

But i am not able to understand how i will connect using REST in this mode ,

 

I cannt get a option to select my NSX manager which i have added in orchestrator because there is not option to select the defined REST API.

 

What can i do in code in order to have  the REST API enabled

 

I am apasting the code that i am trying to use.I am new to programming and hence if there is any mistake in the code plz let me know.

 

/ Return a list of all the EDGE-IDs in XML format (string)

// Note: this works only with the first PAGE of the edge, 200 edges per page

 

// Prepare  request

var arrAuthenticationParams;

arrAuthenticationParams = ["Shared Session", "admin", "PXXXXX"];

 

var objRESTAuthentication;

objRESTAuthentication = RESTAuthenticationManager.createAuthentication("Basic", arrAuthenticationParams);

var host_url = 'https://NSX IP Address/api'

var nsxManagerRestHost = RESTHost(host_url); 

var request = nsxManagerRestHost.createRequest("GET","/2.0/vdn/scopes");

request.contentType = "application/xml";

 

// Esecute request

System.debug("Querying list of first 200 EDGEs");

//System.debug("Request URL: " + request.fullUrl);

var response = request.execute();

 

// Evaluate the response

//System.debug("Response Status Code: " + response.statusCode);

if (response.statusCode == 200) {

    //System.debug("EDGE list is " + response.contentAsString);

    System.debug("Response is Success!");

}

else {

    throw("Failed to get EDGE list! ");

}

 

// Return XML response   

//edgeList = response.contentAsString;

edgeList = response.contentAsString;

System.debug ("Reslut:" + edgeList);

return edgeList;


Viewing all articles
Browse latest Browse all 6251

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>