VMware Cloud Community
machagogo
Contributor
Contributor

Failed Catalog Item Request Using vCACCAFERequestsHelper in vRO - "NativeArray" conversion error?

I'm having trouble figuring out why the Catalog Item request I am making fails.  Using javascript methods in vRO, essentially getting a blank Catalog Item request, converting it to JSON, making modifications, stringifying the modified request and submitting the request.  Seems like the request submission at the very end of the workflow fails for some reason.

I send both the original and modified request data to System.log, and everything seems fine.  I even commented out all the modifications and still get the errors.

Not sure what to look at as the next troubleshooting step.

***

Segment of code where the error occurs :

var modifiedRequest = JSON.stringify(JSONdata, null, "\t");  // I also tried it without null and "\t".  Same error

System.log("Modified Request : " + modifiedRequest);

vCACCAFERequestsHelper.setProvisioningRequestData(provisioningRequest, modifiedRequest);

// Submit request.  Both these fail with same error

// request = System.getModule("com.vmware.library.vcaccafe.request").requestCatalogItemWithProvisioningRequest(catalogItem, provisioningRequest);

request = vCACCAFERequestsHelper.requestCatalogItemWithProvisioningRequest(catalogItem, provisioningRequest);

***

Error message I see in the Logs tab:

<< stringified request that I send to Catalog Item with added modifications.   >>

[2018-09-30 07:54:06.980] [E] Error in (Workflow:Request VM / Get and Submit CatalogItem Request (item2)#38) Cannot convert org.mozilla.javascript.NativeArray@f46e587 to com.vmware.vcac.catalog.rest.stubs.CatalogItem

[2018-09-30 07:54:06.995] [E] Workflow execution stack:

***

item: 'Request VM/item2', state: 'failed', business state: 'null', exception: 'Cannot convert org.mozilla.javascript.NativeArray@f46e587 to com.vmware.vcac.catalog.rest.stubs.CatalogItem (Workflow:Request VM / Get and Submit CatalogItem Request (item2)#38)'

workflow: 'Request VM' (f09230c6-4c67-4a77-9cc6-1db56a5312d0)

<<  Then it lists inputs and attributes  >>

Reply
0 Kudos
1 Reply
machagogo
Contributor
Contributor

I figured out my main problem.

In the sample code "catalogItem" (as in an individual object) is referenced for retrieving, updating and submitting the request.

I was confusing this with an ARRAY of catalogItems I retrieved earlier.  Was fixed in my code by replacing "catalogItem" with "catalogItem[0]" where appropriate.

Reply
0 Kudos