Home > vSphere API > Released: VMware vSphere API and SDK FAQ

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.

Time to learn how to "Google" and manage your VMware and clouds in a fast and secure

Categories: vSphere API Tags: , , ,
  1. March 7th, 2011 at 02:07 | #1

    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
    March 7th, 2011 at 08:12 | #2

    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. March 7th, 2011 at 13:02 | #3

    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. March 7th, 2011 at 13:12 | #4

    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
    March 7th, 2011 at 17:13 | #5

    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 (http://communities.vmware.com/message/1469090#1469090 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. March 7th, 2011 at 21:35 | #6

    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
    July 23rd, 2011 at 16:05 | #7

    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. July 23rd, 2011 at 17:53 | #8

    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. http://vijava.sf.net/forum.php


  9. Srinivasan
    February 1st, 2013 at 07:30 | #9

    Hi Steve,

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


    my mail id : srinivasan.vn@velankani.com

  10. jack
    March 10th, 2014 at 09:59 | #11

    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?


  11. March 10th, 2014 at 10:16 | #12

    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!

  12. Janardan
    July 21st, 2014 at 09:20 | #13

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

  13. February 15th, 2015 at 09:33 | #14

    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?

  14. Imran Khan
    March 4th, 2015 at 02:03 | #15

    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….

  15. March 4th, 2015 at 22:12 | #16

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


  16. Xue Zhang
    May 26th, 2015 at 20:54 | #17

    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
    javax.net.ssl.SSLException: Inbound closed before receiving peer’s close_notify: possible truncation attack?

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

  17. May 26th, 2015 at 22:20 | #18

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


  18. Xue Zhang
    May 27th, 2015 at 04:41 | #19

    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.

  19. May 27th, 2015 at 10:37 | #20

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

  20. Xue Zhang
    May 27th, 2015 at 21:21 | #21

    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!

  21. Xue Zhang
    May 28th, 2015 at 03:37 | #22

    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 WSClient.java. 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?

  22. June 1st, 2015 at 11:04 | #23

    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.


  23. Xue Zhang
    June 2nd, 2015 at 01:01 | #24

    Hi, Steve!
    Thanks for your kindly support!
    I recently wrote a simple java file to connect vCenter server and put “System.setProperty(“javax.net.debug”, “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!

  24. March 1st, 2016 at 11:32 | #25

    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!


  1. No trackbacks yet.