VMware Cloud Community
gjvmc
Contributor
Contributor

PowerCLI/VMC API Exception

Hi All,

We're using PowerCLI 11.4 to pull back information about our VMC SDDCs. Sometime this weekend the method we're using stopped working.

This is a minimal way to reproduce the issue:

connect-vmc -apitoken <token>
$org=get-vmcorg
$sddcsvc=Get-VmcService -Name com.vmware.vmc.orgs.sddcs
$sddcsvc.list($org.id)

This method returns an exception with error message 'Unable to cast object of type 'vmware.vapi.data.OptionalValue' to type 'vmware.vapi.data.StringValue'.' with the attached stack trace.

I'm wondering if anyone else is seeing this. It seems to be happening at the nexus between PowerCLI and the VMC API so I'm not sure which team would be able to address it. 

Thanks

0 Kudos
3 Replies
Zsoldier
Expert
Expert

To narrow down where you need to reach out for support, I would make raw REST calls using invoke-restmethod.

If you get something workable, then it's powercli.  If you get the same garbage, then it might be powershell (Core or Legacy) in general.  Lastly, you can check with something like postman to determine if it's the VMC API endpoint giving you grief.

Chris Nakagaki (中垣浩一)
Blog: https://tech.zsoldier.com
Twitter: @zsoldier
0 Kudos
gjvmc
Contributor
Contributor

I should add that I was able to use the REST API directly via the VMC "Developer Center" to hit the "/orgs/{org}/sddcs" endpoint and pull back the list of SDDCs. I assume that's the same endpoint that is used by PowerCLI.

I have replicated it from several machines here so I suspect something changed in the VMC API that's causing PowerCLI to throw the exception but I'd be curious if anyone outside my org is having the same issue. 

0 Kudos
gjvmc
Contributor
Contributor

Hi All,

Just in case anyone else is experiencing this issue it appears there was a change to the VMC API that impacted the data PowerCLI was expecting to get back. VMware has said they will be applying a fix in the next day or so.

0 Kudos