Quantcast
Channel: VMware Communities : Discussion List - Virtual Disk Development Kit
Viewing all articles
Browse latest Browse all 2039

Issue logging in

$
0
0

So the whole vcloud api in itself seems a bit complicated and not-so-well documented for what I want to do so I tried to use just a basic HTTP Response class to do this whole process.

 

I'm following this guide:

http://www.vmware.com/pdf/vcd_15_api_guide.pdf

 

The error I'm getting: Unexpected HTTP status: 401 Unauthorized


I can login just fine using the vCloud API PHP Class, but using an HTTP authentication it doesn't seem to be working.

 

Here's my code:

 

$user = 'myuser@System';

$pswd = 'mypass';

$url = $this->grabUrl();

 

         require_once 'HTTP/Request2.php';

         $request = new HTTP_Request2($url,

                             HTTP_Request2::METHOD_POST, array('ssl_verify_peer' => false, 'use_brackets' => true));

$request->setAuth($user, $paswd);

 

try {

    $response = $request->send();

    if (200 == $response->getStatus()) {

        echo $response->getBody();

    } else {

        echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .

            $response->getReasonPhrase();

    }

} catch (HTTP_Request2_Exception $e) {

    echo 'Error: ' . $e->getMessage();

}


Viewing all articles
Browse latest Browse all 2039

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>