Hello, I'm attempting to import a configuration element via vCO's REST API (5.5.1 appliance), documented here: http://pubs.vmware.com/vsphere-55/index.jsp?topic=%2Fcom.vmware.vsphere.vco_develop_web_services.doc%2FGUID-75E0F269-3D26-418E-8597-E9FC9E67C608.html
The doc states that you should add request headers to define the properties of the configuration element that you want to import, but gives no specifics. I've tried a few variations but each yield error 400 (bad request). For the purposes of this post I'm using vCO as the REST client as well. I think there may be a chicken and egg issue here, in that you probably have to define a configuration element category (folder) relationship to the imported configuration element - not sure how to do this, but how else would it know where to store the configuration element being imported?
Here's what I've tried:
// I have pre-defined a REST host on the vCO server that points to itself (var restHost) // restHost.url is https://<vco IP>:8281/vco/api var reqString = restHost.url + "/configurations/"; System.log("Request Query: " + reqString); // Got the following content from a REST query to export a config element - this is a vanilla config element var xmlContent = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"yes\"?>\n<config-element " + // I've tried both omitting and including the id //"id=\"CB808080808080808080808080808080038A808001334613384319bad96d0cacb\" + "version=\"0.0.0\" >\n" + "<display-name><![CDATA[test_element]]></display-name>\n<atts>\n" + "</atts>\n</config-element>\n"; var req = restHost.createRequest("POST", reqString); req.contentType = "application/vcoobject+xml;charset=UTF-8"; req.setHeader("contentAsString", xmlContent); var response = req.execute(); System.log("Response: " + response.toSource());
httpResponse:HTTP/1.1 400 Bad Request
VMware Documentation:
1
| In a REST client application, add request headers to define the properties of the configuration element that you want to import. |
2 | Make a POST request at the URL of the configuration element objects: POSThttp://{vcoHost}:{port}/vco/api/configurations/ |
If the POST request is successful, you receive the status code 202.