VMware Cloud Community
Shukran
Contributor
Contributor
Jump to solution

Share vApp with other users using REST API

 

Hello,

 

I am trying to utilize REST APIs to share vApp with other users in the org. I wanted to know can we update controlAccess for the vApp if we have other user's email or username?

 I am trying to use the below endpoint.

 

https://<cloud-url>/api/vApp/<vapp-id>/action/controlAccess

 

 

And I got this payload example from schema.

 

{
  "vCloudExtension": [
    {
      "required": true
    }
  ],
  "isSharedToEveryone": true,
  "everyoneAccessLevel": "string",
  "accessSettings": {
    "vCloudExtension": [
      {
        "required": true
      }
    ],
    "accessSetting": [
      {
        "vCloudExtension": [
          {
            "required": true
          }
        ],
        "accessLevel": "string"
      }
    ]
  }
}

 

 

They payload doesn't specify how we can pass the user detail. I am not sure if this is the correct endpoint or do we have another endpoint?

Thanks,
Shukran

Labels (4)
Reply
0 Kudos
1 Solution

Accepted Solutions
Macleud
Enthusiast
Enthusiast
Jump to solution

Hi Shukran.

You need to use POST /vApp/{id}/action/controlAccess and add ControlAccessParamsType to it.

https://vdc-repo.vmware.com/vmwb-repository/dcr-public/76f491b4-679c-4e1e-8428-f813d668297a/a2555a1b...

https://vdc-repo.vmware.com/vmwb-repository/dcr-public/76f491b4-679c-4e1e-8428-f813d668297a/a2555a1b...

 

<AccessSettings>
        <AccessSetting>
            <Subject href="xs:anyURI" id="xs:string" type="xs:string" name="xs:string"/>

 

 You will need to specify  href, id and username.

View solution in original post

Reply
0 Kudos
4 Replies
Macleud
Enthusiast
Enthusiast
Jump to solution

Hi Shukran.

You need to use POST /vApp/{id}/action/controlAccess and add ControlAccessParamsType to it.

https://vdc-repo.vmware.com/vmwb-repository/dcr-public/76f491b4-679c-4e1e-8428-f813d668297a/a2555a1b...

https://vdc-repo.vmware.com/vmwb-repository/dcr-public/76f491b4-679c-4e1e-8428-f813d668297a/a2555a1b...

 

<AccessSettings>
        <AccessSetting>
            <Subject href="xs:anyURI" id="xs:string" type="xs:string" name="xs:string"/>

 

 You will need to specify  href, id and username.

Reply
0 Kudos
Shukran
Contributor
Contributor
Jump to solution

Hi Macleud,

 

Thanks for your help but when I run it I am getting 415 'Unsupported Media Type' error.


This is the query i have used

curl -L -X POST 'https://<cloud-url>/api/vApp/vapp-01417e65-28bc-4eb4-97fa-f4da9a0158f4/action/controlAccess' -H 'accept: application/*;version=33.0' -H 'Content-Type: application/xml' --data-raw '<?xml version="1.0" encoding="UTF-8"?>
<ControlAccessParams
    xmlns="http://www.vmware.com/vcloud/v1.5">
    <IsSharedToEveryone>true</IsSharedToEveryone>
    <EveryoneAccessLevel>ReadOnly</EveryoneAccessLevel>
</ControlAccessParams>'

 

This is the response

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Error xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:vmw="http://www.vmware.com/schema/ovf" xmlns:ovfenv="http://schemas.dmtf.org/ovf/environment/1" xmlns:vmext="http://www.vmware.com/vcloud/extension/v1.5" xmlns:ns9="http://www.vmware.com/vcloud/versions" majorErrorCode="415" message="Unsupported Media Type" minorErrorCode="UNSUPPORTED_MEDIA_TYPE"/>

 

Not sure if I am doing something wrong. If you have a curl that i could use that would be appreciated.

 

Shukran

Tags (1)
Reply
0 Kudos
Macleud
Enthusiast
Enthusiast
Jump to solution

Content-Type for your request should be 'application/vnd.vmware.vcloud.controlAccess+xml'

Shukran
Contributor
Contributor
Jump to solution

Thanks it works now

Reply
0 Kudos