VMware Cloud Community
rickvelez
Contributor
Contributor
Jump to solution

vCO 5.5.2 and vCAC 6.1 plugin REST API Error

Hello,

I'm getting an error when trying to make calls from vCO 5.5.2 to the vCAC 6.1 REST API requesting catalog items.  This same code works fine with the vCAC 6.0.1 plugin.

Error:

Data serialization error. (Workflow:Test vCAC Rest / Scriptable task (item1)#24)

Code:

var item = {"@type": "CatalogItemRequest",

"catalogItemRef": {"id": "3e6c3f13-6ea0-4da5-8bac-d8cb27e64f24"},

"organization": {"tenantRef": "vcacadmin",

"subtenantRef": "e931debb-6200-40e5-89a7-01d35d0cc306"},

"requestedFor": "vcacadmin@sddc.lab",

"state": "SUBMITTED",

"requestNumber": 0,

"requestData": {"entries": [

{"key": "provider-blueprintId", "value": {"type": "string", "value" : "catalogItem.id"}},

{"key": "provider-provisioningGroupId", "value": {"type": "string", "value": "e931debb-6200-40e5-89a7-01d35d0cc306"}},

{"key": "requestedFor", "value": {"type": "string", "value": "vcacadmin@sddc.lab"}},

{"key": "provider-VirtualMachine.CPU.Count", "value": {"type": "integer", "value": 1}},

{"key": "provider-VirtualMachine.Memory.Size", "value": {"type": "integer", "value": 1024}},

{"key": "provider-VirtualMachine.LeaseDays", "value": {"type": "integer", "value": 0}},

{"key": "provider-__Notes", "value": {"type": "string", "value": "Test"}},

{"key": "provider-VirtualMachine.Disk0.Size", "value": {"type": "string", "value": "40"}}, 

{"key": "provider-VirtualMachine.Disk1.Size", "value": {"type": "string", "value": "8"}}]}}

var catalogRest = vcac.createRestClient(vCACCAFEServicesEnum.CATALOG_SERVICE);

var response = catalogRest.post("consumer/requests",item);

Reply
0 Kudos
1 Solution

Accepted Solutions
rickvelez
Contributor
Contributor
Jump to solution

vCAC 6.0.x plugin is expecting an json object in the rest call.

6.1 plugin is expecting a json string value.


This will do the trick:

var response = catalogRest.post("consumer/requests", JSON.stringify(item));

View solution in original post

Reply
0 Kudos
2 Replies
rickvelez
Contributor
Contributor
Jump to solution

Specific error:

ERROR {vcoadmin@sddc.lab:Test vCAC Rest:a8803401-703f-449d-a088-eab3b2238ea3:ff8080814b6fb8a5014b745d4fc10128} [ResponseErrorHandler] [Rest Error]: {Status code: 400}, {Error code: 10104} , {Error Source: null}, {Error Msg: Data serialization error.}, {System Msg: Could not read JSON: Unexpected token (END_OBJECT), expected FIELD_NAME: missing property '@type' that is to contain type id  (for class com.vmware.vcac.catalog.domain.request.Request)

at [Source: com.vmware.vcac.authentication.http.ServiceHttpServletRequestWrapper$BufferedServletInputStream@100655c6; line: 1, column: 1024]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Unexpected token (END_OBJECT), expected FIELD_NAME: missing property '@type' that is to contain type id  (for class com.vmware.vcac.catalog.domain.request.Request)

Reply
0 Kudos
rickvelez
Contributor
Contributor
Jump to solution

vCAC 6.0.x plugin is expecting an json object in the rest call.

6.1 plugin is expecting a json string value.


This will do the trick:

var response = catalogRest.post("consumer/requests", JSON.stringify(item));

Reply
0 Kudos