VMware Cloud Community
Vsure
Enthusiast
Enthusiast

Property Groups and Definitions with visibility set to All Tenants not returned in Content Management API

How to I get Property Groups and Property Definitions to be included in my results when they have their Visiblitiy set to "All tenants".  It appears that the API is only return results for content that has the visibility set to "This tenant".

example uri with filter for just property groups:

https://<vra host>/content-management-service/api/contents?%24filter=contentTypeId+eq+%27property-group%27

{
    "links":  [

              ],
    "content":  [
                    {
                        "@type":  "Content",
                        "id":  "420f6fcc-d066-414c-a969-c9c063699f7b",
                        "contentId":  "NetworkInformation",
                        "name":  "NetworkInformation",
                        "description":  null,
                        "contentTypeId":  "property-group",
                        "mimeType":  null,
                        "tenantId":  "test",  <<< ONLY RETURNING RESULTS FOR TENANT SPECIFIED IN LOGIN
                        "subtenantId":  null,
                        "dependencies":  "",
                        "createdDate":  "2018-09-03T17:58:55.143Z",
                        "lastUpdated":  "2018-09-03T17:58:55.143Z",
                        "version":  0
                    }
                ],
    "metadata":  {
                     "size":  20,
                     "totalElements":  1,
                     "totalPages":  1,
                     "number":  1,
                     "offset":  0
                 }
}

0 Kudos
7 Replies
daphnissov
Immortal
Immortal

I remember hitting this a while back. I don't think I ever found a resolution whereby the API would return those results.

0 Kudos
qc4vmware
Virtuoso
Virtuoso

Try setting the tenantId to null on your query.  That's what I had to do with the vRO workflows I wrote.

0 Kudos
Vsure
Enthusiast
Enthusiast

Thank you for the replies.  I tested adding a null tenantId to the uri filter but it returned zero results. 

Here are my filter test results:

  • tenantId eq '<mytenantname>' - successfully returns results for the tenant
  • tenantId eq '_Internal' - successfully returns results for _Internal
  • tenantId eq null - zero results returned

I'm pretty sure the "eq null" is the correct way to test for null based reading through: URI Conventions (OData Version 2.0) · OData - the Best Way to REST

I was also successfully able to return all property definitions using the Properties Service (https://<vra-fqdn>/properties-service/api/propertydefinitions) however I was really hoping to use the content management service for all my exporting and importing needs.

I've been playing around with using vRealize Life Cycle Manager Content Management.  I may try to view some logs while it pulls in or resync's the content to see what API calls it's making.

0 Kudos
qc4vmware
Virtuoso
Virtuoso

Maybe just try tenantId eq '' ?

0 Kudos
Vsure
Enthusiast
Enthusiast

I think I did try that also, but I tried again and tenantId eq '' also returns zero results. 

0 Kudos
qc4vmware
Virtuoso
Virtuoso

Have you tried logging into vsphere.local instead of "test" or maybe its an issue with the permissions of the user id you are using?

0 Kudos
Vsure
Enthusiast
Enthusiast

I tried logging into vsphere.local and I get the same results only in this case I just see the contents for the default vsphere.local tenant.  I also tried logging in as administrator@vsphere.local and get the same results there as well.  The account I'm logged into the target tenant with has all roles and does successfully return property groups and definitions when using the properties-service API just not when using the content-management-service.

0 Kudos