How to add an environment using REST API?

Follow

Daphne Burgerhoudt -

Scenario

You want to create a new environment using REST API. This article is an addition to the POST request for a configuration item (CI) from our REST API documentation, to help you out.

Environment

XL Deploy, REST API, version 7.5.x (in this example)

Steps to Perform

Bellow you will find an example of how you can add a new environment using our REST API. In this case a new environment with the name 'was2' is created with 'Infrastructure/was85nd/vagrantCell01' as a reference.

BELOW IS THE CURL COMMAND..

root@user-server:/home/user# cat /home/user/post.xml <udm.Environment id="Environments/was2" > <members> <ci ref="Infrastructure/was85nd/vagrantCell01"/> </members> <dictionaries/> <triggers/> </udm.Environment>

..WITH THE OUTPUT
root@user-server:/home/user# curl -uadmin:admin -X POST -H "Content-type:application/xml" http://127.0.0.1:4516/deployit/repository/ci/Environments/was2 -d@/home/user/post.xml <udm.Environment id="Environments/was2" token="7ca13fbf-d4de-4318-9e15-1dbb83498adc" created-by="admin" created-at="2018-04-02T12:33:33.292+0200" last-modified-by="admin" last-modified-at="2018-04-02T12:33:33.292+0200"> <members> <ci ref="Infrastructure/was85nd/vagrantCell01"/> </members> <dictionaries/> <triggers/>
Caveats (if any)

If you want to make a change to an already existing environment, you can first use the GET request to get all the existing information about your CI. Then make some changes and use the POST request to send those changes to you XL Deploy.

Of course you can also use a GET request as an example to see how your environment looks like, as a help to create your new enviroment.

Additional Information

Documentation about our REST API of version 7.5.x you can find here.

Tags

environment, kb, how-to, xldeploy, xld, restapi

Have more questions? Submit a request