LionelGourdet
Contributor
Contributor

Create a REST/POST request

Hello,

I would like to atomation the creation of my Linux VM by using REST API and Orchestrator, I currently encounter some difficulties to create a REST resquest with POST method from vRO to my RedHat Satellite server.

My RedHat server only takes input json objects parmeters and I don't know how to format the request.

Can you help me to understand how to create a POST request using restOperation.createRequest method and put in my json parameters ?

Regards,

Lionel

2 Replies
ChristianWehner
VMware Employee
VMware Employee

Hi LionelGourdet,

it should be very simple. The method createRequest accepts two inputs: params and the content. When you created the REST operation, you had the possibility to create parameters which gets replaced by anything you store in the params. If you don't specified them, then you can insert null into it and no params will get used.

To create your json, you can simply do this:

var json = {

     "hostgroup" : "mySatelliteHostgroup",

     "location" : "mySatelliteLocation",

     "organisation" : "mySatelliteOrganisation",

     "etc" : "etc"

}

and then the method should look like this:

restOperation.createRequest(null,json);

Of course you need to specify all the necessary attributes and values in the json and I provided just an sample.

Best regards,

Chris

LionelGourdet
Contributor
Contributor

Hi Chris,

It works ! I succeed to run my request correctly.

Thank you very much.

Regards,

Lionel

0 Kudos