VMware Cloud Community
tkongpachith
Contributor
Contributor

Unable to use VMware VSphere REST APIs

Hello,

So I was able to obtain the ZIP folder that contains the REST APIs from the reference this GitHub - vmware/vsphere-automation-sdk-rest: REST (Postman and JavaScript) samples and API reference... . And follow videos from Youtube.

https://youtu.be/vq-7HLY74tQ

https://youtu.be/nr3pJovtbzM

We downloaded the vCenter appliance, installed it onto our servers, and are able to access the vSphere Client page as well as the vCenter Management UI.

However, I put in the necessary variables to reference for the IP address/host, username, and password for our vCenter on Postman.

I followed the steps to use the Authentication > Login API where the Request URL should look like: POST - https://{{vc}}/rest/com/vmware/cis/session

I successfully am able to obtain a session with the Response body being:

{

     "value": ""

}

However, when I continue to say get a List of my datacenter or VMs, with the Request URL being: GET - https://{{vc}}/rest/vcenter/datacenter

I get an error message that states:

{

    "type": "com.vmware.vapi.std.errors.internal_server_error",

    "value": {

        "messages": [

            {

                "args": [

                    "com.vmware.vapi.std.errors.Unauthorized"

                ],

                "default_message": "Provider method implementation threw unexpected exception: com.vmware.vapi.std.errors.Unauthorized",

                "id": "vapi.bindings.method.impl.unexpected"

            },

            {

                "args": [],

                "default_message": "Not authorized to perform this operation.",

                "id": "com.vmware.api.vcenter.unauthorized"

            }

        ]

    }

}

What does this mean? How am I unauthorized if the correct credentials I provided in the Basic Authentication was accurate and gave me a valid session? How is there an Internal Server Error? Or how I am able to log into the browser to the VSphere client and management UI with those same credentials but cannot obtain anything from the APIs with the same information?

Please let me know your thoughts. Thanks!

Reply
0 Kudos
5 Replies
daphnissov
Immortal
Immortal

Ensure you're accessing vCenter using a fully-qualified domain name and not an IP address. You need to get a token in your REST client using FQDN, then make subsequent requests using that FQDN.

Reply
0 Kudos
tkongpachith
Contributor
Contributor

Thank you daphnissov​! But while I have you may you could answer another question I may have..

I added a new datacenter to my vCenter, now I'm trying to add a new Host, like one of our ESXi servers. I try to add them and it prompts me an error message: License not available to perform the operation.The VMware vSphere 6 Hypervisor license for "Host" xxx.xxx.xxx.xxx does not include "vCenter agent for VMware host". Upgrade the license.

Do I need a new license? Do I have to upgrade it? Is there a way I could used this without purchasing or upgrading? I've read other forum posts and they said to use the Evaluation Mode license, but it is already grayed out for me so I assume that's not an option to try.

Please let me know anyone of your thoughts.

Reply
0 Kudos
daphnissov
Immortal
Immortal

It sounds and looks like you have assigned the free license to this host. With that being the case, you cannot manage the host by vCenter. You will most likely have to build a new ESXi host and leave it in evaluation mode to join it to vCenter.

Reply
0 Kudos
tkongpachith
Contributor
Contributor

daphnissov​,

So what you're saying is that since all the ESXi servers are running on the free license that they are UNABLE to be managed on vCenter, correct?

This means that I would have to either build a new ESXi server under the Evaluation Mode license no the free license?

Is there anyway I can have the Evaluation Mode option available? We have VMs installed on our ESXi servers and I do not think we will be able to tear down our servers and have them under another type of licensing. Or do you recommend upgrading our free license to one of the other vSphere licenses? This way to remove any building of new servers etc.

Reply
0 Kudos
daphnissov
Immortal
Immortal

The way I see it, you have two options at your disposal. Pick one:

  1. (Re)install ESXi either on the same hardware or on new hardware so you have access to evaluation mode (only lasts for 60 days).
  2. Purchase an Essentials bundle which comes with a license to vCenter and 6 sockets of ESXi. Change the license on your free ESXi host to use the Essentials key.

Either one will give you the ability to have vCenter manage one or more ESXi hosts.

Reply
0 Kudos