Released: VMware vSphere API and SDK FAQ

After working on this for weeks, I am pleased to announce the first release of VMware vSphere API and SDK Frequently Asked Questions. It includes 70+ questions and trustable answers in 6 different categories: General, Getting Started, Language Bindings, VI Java API, API Usage, Troubleshooting.

From now on, before posting any question to any forum please read this FAQ page. For the best readability, I decided not to allow comments on that page. But your feedbacks and suggestions are always important. Please feel free to use this post for comments and discussions. Based on your inputs, I will continue to enhance the FAQs.

Bothered by SLOW Web UI to manage vSphere? Want to manage ALL your VMware vCenters, AWS, Azure, Openstack, container behind a SINGLE pane of glass? Want to search, analyze, report, visualize VMs, hosts, networks, datastores, events as easily as Google the Web? Find out more about vSearch 3.0: the search engine for all your private and public clouds.

This entry was posted in vSphere API and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.


  1. Posted March 7, 2011 at 2:07 am | Permalink

    Hi Steve, great write-up and a very complete API & SDK FAQ.
    Very useful, and not only for VI Java users!

    Perhaps an additional clarification, PowerCLI is not only built on top of the vSphere API, but also comes with a framework to use the API.

    And since you compared the number of lines, I couldn’t resist the temptation to show the 9 lines of PowerCLI code to do the same 😉

    Connect-VIServer -Server MyServer
    $eventMgr = Get-View EventManager
    $eventFilter = New-Object VMware.Vim.EventFilterSpec
    $ehc = Get-View ($eventMgr.CreateCollectorForEvents($eventFilter))
    $ehc.LatestPage | Select @{N=”Event”;E={$_.GetType().Name}}

  2. Tos2k
    Posted March 7, 2011 at 8:12 am | Permalink

    Hi Steve!

    Two questions widely related to viJava:

    Do you plan a converter viJava? What are you meanings around that? Basically, concerning Converter API, developers are facing the same problem programming based on Axis (which is slow)?!
    If not 😉 what hints could you give me (aka the community) to make a converterViJava port?

    viJava Virtualmachine: How can i extend the vijava VirtualMachine? This is tricky as it lacks the empty constructor. Is that by design from your side? What tips/advice can you give on extending VirtualMachine?


  3. Posted March 7, 2011 at 1:02 pm | Permalink

    Hi Luc,

    Thanks for your comment! If you want to write up several FAQs for PowerCLI, I would be more than happy to include them or link to them. I am going to ask William Lam as well for VI Perl.

    Compared with my Java code, your code does not have explicit parsing for server url, user name, password, etc. Plus, I always have opening { in its own line and no pipeline within one line. So it’s not a fair comparison. Also, don’t forget we can use Scala, Jython, etc. to beat the LOC if needed. :-)


  4. Posted March 7, 2011 at 1:12 pm | Permalink

    Great questions Tos2k,

    So far I don’t have a plan on a converter. As I can see today, most developers and companies are using VI Java API. Therefore I don’t see much value for such a converter.

    In terms of conversion, it’s pretty simply and straight-forward. Mostly you just need to locate the method calls and change them to VI Java API. Data objects in VI Java API and Apache AXIS are 100% compatible. That is a design decision I made when I work on the VI Java 2.0.

    For the extensibility, I have actually included a FAQ under the VI Java API section. You can double check there. I know there are quite many FAQs.


  5. stud-muffin
    Posted March 7, 2011 at 5:13 pm | Permalink

    Hello Steve,

    I’m interested in this FAQ “What if I want to use REST API?”. I read a post of yours on VMware communities ( regarding a VMware partner who has used Jython with VI Java API to create a REST bridge to your API. Can you provide some more details on this?

    The second option is using your Client REST api. I can’t find a lot of information on this besides your Java example and a Jython example. I would like to know a couple of things:

    – You say that most of the SOAP stuff can be done with the REST api. Do you have a list or way for me to know what I can’t do?

    – The methods are different between VI Java API and REST API, so what’s an easy way to know how to call something like this in the latter:

    vmxPath = vm.getConfig().getFiles().getVmPathName()
    vmPowerstate = vm.getRuntime().getPowerState()

    – Is it too risky to use the REST api since an application using it will stop functioning if VMware decides to remove the XML?

    – In your opinion would it be better to create a REST interface for VI Java API rather than use the Client REST api?

    – Is anyone using the Client REST api in a commercial product?

    Thanks in advance.

  6. Posted March 7, 2011 at 9:35 pm | Permalink

    Quite a few great questions here.

    1. For the partner case, they use VI Java API to build their own REST API with high level of abstraction.
    2. Client REST API:
    – I haven’t looked into this deeply but as far as I can tell now all the SOAP stuff can be done in the Client REST API.
    – Once you get the XML, you can use whatever approach, for example, XPATH, to get hold of the values.
    – It’s risky as you said it, but I don’t see it will be changed any time soon.
    – it’s better to build REST API on VI Java API instead of MOB as it is for the Client REST.
    – I don’t know a specific developer use the Client REST, but I got quite a few questions in the VI Java API forum before.


  7. Pallavi E
    Posted July 23, 2011 at 4:05 pm | Permalink

    Hi Steve ,

    i tried using VI java API for customizing the ipaddress alone for template but it is throwing error.. can you please help me? i was able to customize ip address for linux template but for windows it is very challenging

    Thanks in advance :)

  8. Posted July 23, 2011 at 5:53 pm | Permalink

    Hi Pallavi,

    Have you checked the vijava API forum? I remember there was a discussion on it. If it does not address your issue, post another question there.


  9. Srinivasan
    Posted February 1, 2013 at 7:30 am | Permalink

    Hi Steve,

    Please could you provide the URL to download jar file for below package.

    my mail id :

  10. Posted February 1, 2013 at 11:42 am | Permalink
  11. jack
    Posted March 10, 2014 at 9:59 am | Permalink

    HI and first of all thx for the great work,

    I only touched pyvmomi so far but its awsome.

    Here is my question:
    in powercli i can just skip giving credentials to “Connect-VIServer” and it takes the credentials from the user that is running the script (so they wont be in script plain text).
    Could give me a pointer if that is possible with python and pyvmomi?


  12. Posted March 10, 2014 at 10:16 am | Permalink

    Hi Jack,

    I am glad you find it useful.

    For the question, I haven’t tried it myself. But I think you can easily wrap it in Python with something like this to get password:

    import getpass
    pw = getpass.getpass()

    Good luck!

  13. Janardan
    Posted July 21, 2014 at 9:20 am | Permalink

    please send code to create host Datacenter folder etc.
    also specify parameter value.

  14. Posted February 15, 2015 at 9:33 am | Permalink

    Hi Steve,

    Do you have post on importing SSL certs and providing path to keystore while connecting to vCenter or ESXi using ServiceInstance() method?

    It would be great if I get some pointers on this.

    Also, is there any plan to add vSphere 6.0 API support as well?

  15. Imran Khan
    Posted March 4, 2015 at 2:03 am | Permalink

    Hello Friends,
    I want to install applications on my guest os on esxi by using vijava. how can i do this? give me Some idea….

  16. Posted March 4, 2015 at 10:12 pm | Permalink

    Try the guest API in the vSphere API since 5.0. Good luck,


  17. Xue Zhang
    Posted May 26, 2015 at 8:54 pm | Permalink

    hi, Steve!
    Thanks for your great job!
    In native JRE environment, the provider “SunJSSE” is used to SSL connection. When I create an instance for ServiceInstance, it works just fine. But if we use the provider “RsaJsse”, an exception occurs:
    Exception caught while invoking method: RetrieveServiceContent Inbound closed before receiving peer’s close_notify: possible truncation attack?

    Could you give some suggestions on solving this?
    Thanks so much!

  18. Posted May 26, 2015 at 10:20 pm | Permalink

    Hi Xue, glad you find it useful. What is the reason for you to use RsaJsse instead of the default?


  19. Xue Zhang
    Posted May 27, 2015 at 4:41 am | Permalink

    Hi, Steve!
    Thanks so much for your reply!
    I asked the same question. And here is what I got from one of my colleagues:

    The RSA libraries are placed first in the priority order to ensure they are used instead of the stock JSSE provider for SSL connections. This gives us better security and is necessary for FIPS compliance in a production system.

    So I believe this is necessary for us and I have to work on the compatibility problem right now. But, seriously, I am new the area and have many confusions. I think I really need someone to give me some advice about the solution direction or whatever. Could you please help me?

    Thanks again.

  20. Posted May 27, 2015 at 10:37 am | Permalink

    You are welcome Xue, what is the key length you plan to use for encryption?

  21. Xue Zhang
    Posted May 27, 2015 at 9:21 pm | Permalink

    Hi, Steve!

    I will figure this out later and keep you informed.
    Basically, right now I would like someone could give me some advice on what direction I should search to solve this problem. Because I am kind of lost right now. And you are the person most familiar with vijava obviously.
    So could you please give me some guidance?
    Thank you!

  22. Xue Zhang
    Posted May 28, 2015 at 3:37 am | Permalink

    Hi, Steve!
    After confirmation, we will use
    ” new ServiceInstance(new URL(url.toString()), user.toString(), pass.toString(), true);” to create the instance of ServiceInstance. But right now the problem is this will go wrong at “OutputStream os=postCon.getOutputStream();” in the method post() in It cannot connect to the server. So the only reason it cannot work is we use the RsaJsse provider. Should I try to write a SSL client to test if it can work under the same environment?

  23. Posted June 1, 2015 at 11:04 am | Permalink

    Hi Xue,

    If I remember correctly, there are a few options in the Java command line that allows more verbose output for the SSL handshaking where I think the problem is. Good luck with it.


  24. Xue Zhang
    Posted June 2, 2015 at 1:01 am | Permalink

    Hi, Steve!
    Thanks for your kindly support!
    I recently wrote a simple java file to connect vCenter server and put “System.setProperty(“”, “ssl,handshake”);” in it to see the detailed process of SSL connection.

    The first server I try to connect is vCenter 5 we used to use and the second one is vCenter 6.
    I investigate the SSL handshake process:
    1. ClientHello (Client -> Server)
    2. ServerHello (Server -> Client)
    3. ServerKeyExchange (Server -> Client)
    4. ServerHelloDone (Server -> Client)
    5. ClientKeyExchange (Client -> Server)
    6. ChangeCipherSpec (Client -> Server)
    7. Finished (Client -> Server)
    8. ChangeCipherSpec (Server -> Client)
    9. Finished (Server -> Client)

    It seems like that when connecting to vCenter 6, the 8th and 9th processes are missing. The SSL handshake stops with an exception occurring. I am trying to figure out the reason.
    Please let me know if you have any suggestions. Thanks!

  25. Posted March 1, 2016 at 11:32 am | Permalink

    Hi Steve,

    Hope you are well! I insist that you publish a new version of your “VMware VI and vSphere SDK book! : ) It has been indispensable for me in understanding more about the API structure. Thank you!

    My question is probably a very basic one for you. When enumerating various Managed Objects – let’s say a portgroup – I see various properties listed and then I see a “spec” object with most of the same properties again. For creating a baseline inventory of Managed Objects and their relevant properties – should I ignore the “spec” property values?

    I’ve tried to come to an understanding of what the “spec” is used for and it seems that it is for the express purpose of configuration of a Managed Object. Given my example of a building out an inventory of relevant portgroups and their properties – I shouldn’t use the “spec” properties to populate my inventory collection scripts. I would only use the “spec” properties to build out a portgroup.

    Is my understanding correct?

    Thank you!


Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


    My company has created products like vSearch ("Super vCenter"), vijavaNG APIs, EAM APIs, ICE tool. We also help clients with virtualization and cloud computing on customized development, training. Should you, or someone you know, need these products and services, please feel free to contact me: steve __AT__

    Me: Steve Jin, VMware vExpert who authored the VMware VI and vSphere SDK by Prentice Hall, and created the de factor open source vSphere Java API while working at VMware engineering. Companies like Cisco, EMC, NetApp, HP, Dell, VMware, are among the users of the API and other tools I developed for their products, internal IT orchestration, and test automation.