VMware {code} Community
gwc_sage
Contributor
Contributor

trouble running vCloud Director API 5.1/5.5 for .NET Sample code specifically the vClient.Login method

I'm trying to determine what needs to be done in order to get the Samples 'login' to work.   The URL and credentials I provide that work successfully when using the REST-Client in Mozilla do not

work with the Samples code and return the message 'There is an error in the XML document (1,1).

So, I really have a couple of questions here...

   1) Is it just the way our vCloud Director environment has been setup that causes the issue?  details on our environment as I know it currently are provided below

   2) Is it the Sample code that isn't flexible to work with the environment we have and if not,  is there actual 'Source' code for the vCloudSDK_v5.x.dll provided that I could modify to allow it to work.

We login to our Webclient using the URL    https://vcloud.xx.com/cloud/org/our_org_name   and provide our login username and password

using the GET command for accessing the supported API versions using the Mozilla REST-client I use this URL   https://vcloud.xx.com/api/versions

and it returns this information

   <VersionInfo>

          <Version>5.1</Version>

          <LoginUrl>https://vcloud.xx.com/cloud/api/sessions</LoginUrl>

If I try to use that 'LoginUrl'  specified url through the REST-Client or Samples  it returns the status code of '404 Not found' or 'No error report - 404'.

The login URL that works through the Mozialla REST-Client is  https://vcloud.xx.com/api/sessions with my username@org_name and password  however using this

same URL with the .NET Sample code gives the 'XML document error' that I mentioned above.

The data returned via the Mozilla REST-Client for the login lists all the 'href' attributes with a URL like this  https://vcloud.xx.com/cloud/api/org  or vdc or catalog but

trying to simply use those URLs doesn't work UNLESS I take out the '/cloud' portion so it looks like this  https://vcloud.xx.com/api/org  or vdc or catalog.

So if I write code to gather this information the 'href' data I would have to massage to make it appropriate which doesn't seem quite right.

Thank you to anyone would might have information.

0 Kudos
8 Replies
rkamal
VMware Employee
VMware Employee

Can you provide the code snippet which you are using for login? Also provide the inputs provided to the snippet.

Also can you also provide the execution logs of that code snippet?

What is the SDK and vCD versions that you are using

0 Kudos
gwc_sage
Contributor
Contributor

I'm using the code out of the Samples folder that comes with the zip download of vCloud Director API v5.1 or 5.5.

so the code looks like this

try

{

    vCloudClient client = new vCloudClient(args[0], com.vmware.vcloud.sdk.constants.Version.v5_1)  (I've tried v5_5  and v1_5)

    client.Login(args[1], args[2])       <---- here is where it fails

    ...

}

It's compiled with VS 2010 SP1  and I've also tried on a machine using VS 2012  and I've got the Microsoft.Http library(System.Net) copied into the executable location as the README.txt file talked about.

The arguments are provided as:

   https://vcloudwest.xx.com/api/sessions    username@org_name  mypassword

when using these parameters I get the 'error in XML document (1,1)

I've also tried  https://vcloudwest.xx.com    username@org_name  mypassword

it returns the 404 error

I've also tried https://vcloudwest.xx.com/cloud/api/sessions   username@org_name mypassword

it returns the 404 error

I've tried using both the vCloud SDK API 5.1  and 5.5 downloads against  our vCD which is at version 5.5.

What execution log are you looking for?

Read through my whole post above regarding how I login to the WebClient to start with and the data I got back just using the non-authenticated GET versions.

Thanks

0 Kudos
gwc_sage
Contributor
Contributor

rkamal

was wondering if you saw my reply and if you had any other information potentially.

Thanks

0 Kudos
cfor
Expert
Expert

No clue if this could be it or not...

You said:

I've also tried https://vcloudwest.xx.com/cloud/api/sessions   username@org_name mypassword

it returns the 404 error

Have you tried:

URL: https://vcloudwest.xx.com

User: adminaccount@system

I am not sure how the samples handle org level logins but if they need system level things @system would be needed.

ChrisF (VCP4, VCP5, VCP-Cloud) - If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
0 Kudos
rkamal
VMware Employee
VMware Employee

Hi,

The VcloudClient class in the Samples/SDK expects an URL of this format.

I've also tried  https://vcloudwest.xx.com    username@org_name  mypassword

it returns the 404 error

I see that you have tried it and it says 404.

What happens when you try this in the browser - https://vcloudwest.xx.com/api/versions ??

Is there any proxy to reach this box? If so, can you try setting the proxy using the setProxy in the VcloudClient class.

0 Kudos
gwc_sage
Contributor
Contributor

I tried the userxxx@system account with the https://vcloudwest.xx.com URL and that returned a message saying 'Header was not found'.   I don't think

we have a '@system' type org setup at least from talking to our local IT person but he does not have full rights to vCloud so he couldn't say for sure.

0 Kudos
gwc_sage
Contributor
Contributor

rkamal-

When I try the url   https://vcloudwest.xx.com/api/versions   with GET from Mozilla it returns the VersionInfo information

I provided in the original post.    The 'LoginUrl' it listed https://vcloudwest.xx.com/cloud/api/sessions  I was not able to use successfully either. 

I have no proxy server available to try sorry to say.

0 Kudos
gwc_sage
Contributor
Contributor

rkamal

Here is some more data I just gathered.    I found out that the System Settings for the API that our company setup

is this...

https://vcloudwest.xx.com/cloud   (again we are using VCD Version 5.5)

Should this actually be set to just 'https://vcloudwest.xx.com'     without the trailing '/cloud'?

With the current setting is that potentially what is causing the problems with using the SDK Samples?

Thanks

0 Kudos