SeanKohler
Expert
Expert

And on and on and on it goes... with no help because nobody knows... :smileymischief:

Using vCAC 6 REST APIs - Part 1 - Elastic Skies

Using vCAC 6.X REST APIs - Part 2 - Elastic Skies

So based on those, grabbed the post data during a lease extension.  Gave it the old college try, and I get 403 errors during the post.

403.jpg

====================

403ad.jpg

/*
System.log(vcacvm.virtualMachineID);
System.log(vcacvm.virtualMachineName);
System.log(expirydate.getFullYear());
System.log(expirydate.getMonth()+1);
System.log(expirydate.getDate());
System.log(expirydate.getHours());
System.log(expirydate.getMinutes());
*/

var datestring = expirydate.getFullYear()+"-"+(expirydate.getMonth()+1)+"-"+expirydate.getDate()+"T"+expirydate.getHours()+":"+expirydate.getMinutes()+":00.000-0700";
System.log(datestring);

// pulled using firebug, straight from valid POST during lease extension

var leaseExtend = {
   "@type":"ResourceActionRequest",
   "resourceRef":{
      "id":"33a87fe2-52a9-43a9-bb27-37fb433f3017"
   },
   "resourceActionRef":{
      "id":"a2557742-1727-42c2-8e31-f57ade5a8097"
   },
   "organization":{
      "tenantRef":"vsphere.local",
      "tenantLabel":"vsphere.local",
      "subtenantRef":"55b46852-602a-497d-88fc-3368068e44a2",
      "subtenantLabel":"PRIVATE-INFO"
   },
   "state":"SUBMITTED",
   "requestNumber":0,
   "requestData":{
      "entries":[
         {
            "key":"provider-operationId",
            "value":{
               "type":"string",
               "value":"Infrastructure.Machine.Action.ChangeLease"
            }
         },
         {
            "key":"provider-machineId",
            "value":{
               "type":"string",
               "value":vcacvm.virtualMachineID
            }
         },
         {
            "key":"provider-MachineName",
            "value":{
               "type":"string",
               "value":vcacvm.virtualMachineName
            }
         },
         {
            "key":"provider-ExpirationDate",
            "value":{
               "type":"dateTime",
               "value":datestring
            }
         }
      ]
   }
}
leaseExtend = System.getModule("org.dojotoolkit.dojo.json").serialize(leaseExtend);
//System.log(leaseExtend);


var catalogRest = host.createRestClient(vCACCAFEServicesEnum.CATALOG_SERVICE);
System.log(catalogRest.getUrl()); // Results in good URL response so service is created

//Falls over
var response = catalogRest.post("consumer/requests/",leaseExtend);
System.log(response);


Reply
0 Kudos