Hi,
I'm using vRA and vRO 7.3.0 and I want to get the detail of a catalog item request from vRO. I want to have access to request information, like in vRA. For example, for a machine blueprint request, vRA shows us CPU, components description, custom properties, etc. All user inputs are available:
I try to get the same information using vRO or the vRA API but without success. I can get some request common information, but not the detail of the input form like above.
I'm using this API call to get the request : https://{{va-fqdn}}/catalog-service/api/consumer/requests?$filter=requestedFor eq '{{username@domain}}'
I think that data I want should be in the "requestData" section, it's why I understand here: https://communities.vmware.com/thread/535074#2599862. But all that I have is something like this:
"requestData": {
"entries": [
{
"key": "provider-_leaseDays",
"value": null
},
{
"key": "provider-vSphere__vCenter__Machine_1",
"value": {
"type": "complex",
"componentTypeId": null,
"componentId": null,
"classId": null,
"typeFilter": null,
"values": {
"entries": []
}
}
},
{
"key": "provider-vSphere__vCenter__Machine_2",
"value": {
"type": "complex",
"componentTypeId": null,
"componentId": null,
"classId": null,
"typeFilter": null,
"values": {
"entries": []
}
}
}
]
}
Not very useful. When I get the request with vRO (either with vCACCAFEEntitiesFinder or vCACCAFECatalogConsumerRequestService) I have the same result.
I know that data I need are somewhere (I can see it in vRA), but I have no idea where to look for it.
Thanks for your help!
Hi biarn
Can you provide a few more details? at what lifecycle stage are you trying to get this information, is it via an event broker subscription whilst the request is in progress, via an approval policy subscription or just as an ad hoc api call against a completed request. Also are you using out of the box IaaS Catalog Items to request the VMs or are you using an XaaS Catalog Item as a wrapper around the IaaS request. Also any reason why you are filtering a request based on the user it was requested for and not the request id?
As an example of what I have done in the past, here is a sample of some code I use to get details about an IaaS request (in my case it was called by an XaaS workflow so I am looking for the inputs for the IaaS request to understand what was passed from vRO. The requestId parameter is the request id of the IaaS request). In my example the code was part of a post approval event broker subscription against the XaaS request, so it did not kick in until the IaaS request the VMs are provisioned under has completed. As long as you are running it after the IaaS request is complete you can use similar code.
if(requestId){
var endpoint = 'com.vmware.csp.core.cafe.catalog.api';
var restClient = cafeHost.createRestClient(endpoint);
//set the url for the REST call to be the consumer service and include the request id as the value to retrieve results for
var catalogRequestUrl = "consumer/requests/" + requestId + "/forms/details";
//make the REST call and retrieve the results in string format
var catalogRequestFormDetails = restClient.get(catalogRequestUrl);
var results = catalogRequestFormDetails.getBodyAsString();
//replace any special characters in the results
var json = JSON.parse(results.replace(/\\/g,''));
//drill down through the JSON structure to get to the section holding the input/output parameters from the request
var jsonResults = json.values.entries;
//the values.entries section is an array with key value pairs, the value attribute also includes a type and value property
//which contains the value assigned to the parameter in the request
for(i=0; i< jsonResults.length;i++){
if(jsonResults[i].key == iaasRequestOutputName){
System.debug("matching parameter found in JSON results for the IaaS Request output parameter. Retrieving value of the parameter.");
iaasRequestId = jsonResults[i].value.value;
System.debug("IaaS Request ID retrieved from the JSON results is: " + iaasRequestId);
break;
}
}
}
else{
System.debug("no request Id was passed for API call");
}
Hi biarn
Can you provide a few more details? at what lifecycle stage are you trying to get this information, is it via an event broker subscription whilst the request is in progress, via an approval policy subscription or just as an ad hoc api call against a completed request. Also are you using out of the box IaaS Catalog Items to request the VMs or are you using an XaaS Catalog Item as a wrapper around the IaaS request. Also any reason why you are filtering a request based on the user it was requested for and not the request id?
As an example of what I have done in the past, here is a sample of some code I use to get details about an IaaS request (in my case it was called by an XaaS workflow so I am looking for the inputs for the IaaS request to understand what was passed from vRO. The requestId parameter is the request id of the IaaS request). In my example the code was part of a post approval event broker subscription against the XaaS request, so it did not kick in until the IaaS request the VMs are provisioned under has completed. As long as you are running it after the IaaS request is complete you can use similar code.
if(requestId){
var endpoint = 'com.vmware.csp.core.cafe.catalog.api';
var restClient = cafeHost.createRestClient(endpoint);
//set the url for the REST call to be the consumer service and include the request id as the value to retrieve results for
var catalogRequestUrl = "consumer/requests/" + requestId + "/forms/details";
//make the REST call and retrieve the results in string format
var catalogRequestFormDetails = restClient.get(catalogRequestUrl);
var results = catalogRequestFormDetails.getBodyAsString();
//replace any special characters in the results
var json = JSON.parse(results.replace(/\\/g,''));
//drill down through the JSON structure to get to the section holding the input/output parameters from the request
var jsonResults = json.values.entries;
//the values.entries section is an array with key value pairs, the value attribute also includes a type and value property
//which contains the value assigned to the parameter in the request
for(i=0; i< jsonResults.length;i++){
if(jsonResults[i].key == iaasRequestOutputName){
System.debug("matching parameter found in JSON results for the IaaS Request output parameter. Retrieving value of the parameter.");
iaasRequestId = jsonResults[i].value.value;
System.debug("IaaS Request ID retrieved from the JSON results is: " + iaasRequestId);
break;
}
}
}
else{
System.debug("no request Id was passed for API call");
}
Hi,
For now, I need this information at pre-approval stage, with a workflow launched by the event broker. I want this workflow to check request form inputs and approve or not the request. In particular, I want to force users to fill the description field of all virtual machine components in addition of the blueprint description. This is my final goal.
I am using out of the box IaaS Catalog Items to request the VMs and I have no reasons to filter requests by username. I'm using IDs, I copied the wrong API call from postman, my mistake.
So the actual API call is: https://{{va-fqdn}}/catalog-service/api/consumer/requests/{{requestId}}
What we have with the "forms/details" call is not exactly the same as we can see in the vRA portal (some information are missing) but we can have a lot of data, including the component description that I was looking for. In fact I have already tried this API call, but in some cases it does not work as expected (ie: as I expect). And, of course, when I tried it I was in a non-working case... so I thought it was not working at all. If the user keep the default value for a field, this value will not be available in the "forms/details" view. So I still can't have the same data as the web UI but know I know why and I'm able to check descriptions. So I mark this subject as resolved, and thanks for your help!
I what I say is not clear, I can provide an example.
Hi guys,
I know this is an old thread, but I had the same issue today and that's what I found (on vRA 7.5):
Hope it can help someone ^^
If it's not clear enough feel free to ask for more details here !
Cheers,
Tim.