VMware Cloud Community
aturli
Contributor
Contributor

vRA 6.1 API problem with POST /catalog-service/api/consumer/requests

Hi, I'm using vCloud Automation Center 6.1 and I'd like to use its REST API from a java client that I'm writing. Some of the API methods are working as expected but for

REQUEST

>> "{"@type":"CatalogItemRequest","catalogItemRef":{"id":"752ae9bd-abcd-4dc4-b425-6f5e3c8620b0"},"organization":{"tenantRef":"MY_TENANT","subtenantRef":"BUSINESS_GROUP_ID"},"requestedFor":"MY_USER","state":"SUBMITTED","requestNumber":0,"requestData":{"entries":[{"key":"provider-blueprintId","value":{"type":"string","value":"e32edcf1-6a10-4bc7-98e2-a23245aeb857"}}]}}"

>> POST https://VRA_URL/catalog-service/api/consumer/requests HTTP/1.1

>> Accept: application/json >> Authorization: Bearer MTQyNzg4NjEyNTg3N...mM0MTQ=

>> Content-Type: application/json >> Content-Length: 355

RESPONSE

<< HTTP/1.1 400 Bad Request

<< Vary: Accept-Encoding,User-Agent

<< Date: Wed, 01 Apr 2015 11:02:16 GMT

<< Connection: close

<< Pragma: no-cache

<< Cache-Control: no-cache, no-store

<< Content-Type: application/json;charset=UTF-8

<< Content-Length: 745 << Expires: Thu Jan 01 00:59:59 CET 1970

<< "{"errors":[{"code":10104,"message":"Data serialization error.","systemMessage":"Could not read JSON: Unable to unmarshal (to type [simple type, class com.vmware.vcac.catalog.domain.rest.OrganizationReference]): Invalid argument. (through reference chain: com.vmware.vcac.catalog.domain.request.CatalogItemRequest[\"organization\"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Unable to unmarshal (to type [simple type, class com.vmware.vcac.catalog.domain.rest.OrganizationReference]): Invalid argument. (through reference chain: com.vmware.vcac.catalog.domain.request.CatalogItemRequest[\"organization\"]) [acceptableTypes: [application/*+json;charset=UTF-8, application/json;charset=UTF-8]]","moreInfoUrl":null}]}"

It seems like the json string that I'm posting is not valid because of "organization" field. But both the official doc http://pubs.vmware.com/vCAC-61/topic/com.vmware.ICbase/PDF/vcloud-automation-center-61-programming-g... and/or this blog post http://www.vmtocloud.com/vrealize-automation-rest-api-with-curl/ contain a similar json request.

Any ideas?

Thanks,

Andrea

Tags (3)
Reply
0 Kudos
6 Replies
GrantOrchardVMw
Commander
Commander

That looks identical to what I have, here is a capture from Kaleidescope:

pastedImage_0.png

Since your syntax is right, I'd suggest trying to capture a working request from the UI using something like Firebug or Chrome's developer tools.

Grant

Grant http://grantorchard.com
aturli
Contributor
Contributor

Thanks GrantOrchardVMware I think this is really helpful, I think I'm not specifying the right business group id

Do you know a simple way to get it from APIs or web console?

Thanks

Reply
0 Kudos
GrantOrchardVMw
Commander
Commander

You should be able to do a GET against https://<vcac hostname>/identity/api/tenant/<tenant_name>/subtenants

From there you will have the ID. Let me know how you get on.

Grant

Grant http://grantorchard.com
Reply
0 Kudos
aturli
Contributor
Contributor

I'm getting HTTP 404 with that URL. I'm using vCAC 6.1, is that API available with that version?

Thanks,

Andrea

Reply
0 Kudos
GrantOrchardVMw
Commander
Commander

EDIT: my bad - it's tenants not tenant.

Hmm, strange. This worked in 6.1 for me thought I'm on 6.2 now. Here is my result:

pastedImage_0.png

Grant

Grant http://grantorchard.com
aturli
Contributor
Contributor

Thanks GrantOrchardVMware for your help!

I was finally able to get the request machine sorted using something similar to what you were doing for /subtenants API: firebug helped me on finding the right parameters to build the json object

Thanks

Andrea

Reply
0 Kudos